How do I typedef a function that returns another function of the same type?

dart

Solution

Sorry, this is not allowed by the spec right now. You could open a feature request at http://dartbug.com/new

Using an object or returning Function, as you mention, would be the best ways to go right now.

Problem

I'm implementing a state machine in dart, and I'd like to have my state functions return other state functions, but ``` typedef State State(foo); ``` Gives me an error: ``` typedef 'State' illegally refers to itself ``` Is there any way to do this typedef? Obviously I could wrap it in a class or have it return `Function`, but I was hoping to do this with typedef.

Original source