Recursive Declarations (for functions).
Russell Lewis
webmaster at villagersonline.com
Sat Aug 25 12:26:28 PDT 2007
Leandro Lucarella wrote:
> Hi. I was designing a FSM and I wanted to use a simple scheme where a
> state is represented with a function which returns a pointer to the next
> state (function) when I realized there is no support in the language to
> declare a function that returns a function with the same signature as
> itself.
>
> Here is an explanation of the problem and suggested solutions for C++:
> http://www.gotw.ca/gotw/057.htm
>
> AFAIK you can implement something similar in D, but D doesn't have a
> "native" solution either.
>
> What I want to know is if it's even posible to have a nice syntax to
> support this, something like:
>
> fp function() fp;
>
> Is the type system capable of handling this?
You're not the first to think that this is an intriguing concept!
However, the type system doesn't support it with any "nice" syntax.
More information about the Digitalmars-d
mailing list