Currently functions have two subtypes: normal ones (0) and builtin functions (USHRT_MAX). What would be the implications of adding two more?
Not quite correct; normal ones are 0..USHRT_MAX-1 and builtin functions are USHRT_MAX. The subtype is used to select the function entry in the function table for the object.
I propose adding FUNCTION_GENERATOR and FUNCTION_GENSTATE to differentiate continue functions, and the state functions that they return; and also a Pike-callable Function.function_type which will return the corresponding type. Thus:
AFAIR there already is a separate function entry for the continue function.
continue int demo() { }
Function.function_type(demo) == 1 Function.function_type(demo()) == 2
Alternatively, if this doesn't need to be a subtype, is there a way to recognize them already? I'm poking around, trying to implement this, but I think more information needs to be carried through to runtime - might be wrong though.
AFAIR the generator function gets the suffix "\0generator" appended to its function name, but I'm uncertain whether this is visible at the Pike code level.
There may also be a difference in the value returned by _typeof().
/grubba