"recursive" function prototype?
Bakul Shah
bvs at light.uucp
Sat May 7 09:22:11 AEST 1988
The following is not exactly what was asked for but it is the only way
in C of defining self-type returning functions _without_ using casts.
struct state {
struct state (*next)(struct state);
};
Example use:
state_machine(struct state initstate)
{
struct state state = initstate;
while (state.next)
state = state.next(state);
}
The need for some extra syntactic sugar is unfortunate but (to my way of
thinking) preferable to use of ``casts'' or ``void (*)()''s. Of course,
in practice you rarely want to use a function that returns another
function of the same type.
--
Bakul Shah
..!{ucbvax,sun}!amdcad!light!bvs
More information about the Comp.lang.c
mailing list