The function code is a bit of a mess, particularly where it comes to a division between native Python functions and Flitter functions. This is what I think needs doing:
debug() should just be a @context_func in functions.pyx and all special pleading for it removed
move references into the Context class and make sample() a @context_func as well
allow func to declare recursive functions – this should just be a case of adding the function name before the parameters onto lnames list before compiling the body and then pushing it onto the lnames stack as part of the calling convention
box all Flitter functions as Python function-like objects – basically turn call_helper() into a callable class wrapper around func Programs
make all function calling use the Python call convention – dump CallFast and have Call just use PyObject_CallObject() or PyObject_Call() depending on whether any kwargs have been popped off the stack
let the normal Python call stack handle and throw recursion errors as necessary
An advantage of all of this is that it will allow for higher-order functions, like passing Flitter functions into native functions as arguments. It'll also let me Cython-optimise the, currently quite slow, sample() function.
This also paves the way for possibly allowing functions to be passed into the rendering pipeline as attributes of Nodes…
The function code is a bit of a mess, particularly where it comes to a division between native Python functions and Flitter functions. This is what I think needs doing:
debug()
should just be a@context_func
infunctions.pyx
and all special pleading for it removedContext
class and makesample()
a@context_func
as wellfunc
to declare recursive functions – this should just be a case of adding the function name before the parameters ontolnames
list before compiling the body and then pushing it onto thelnames
stack as part of the calling conventioncall_helper()
into a callable class wrapper around funcProgram
sCallFast
and haveCall
just usePyObject_CallObject()
orPyObject_Call()
depending on whether anykwargs
have been popped off the stackAn advantage of all of this is that it will allow for higher-order functions, like passing Flitter functions into native functions as arguments. It'll also let me Cython-optimise the, currently quite slow,
sample()
function.This also paves the way for possibly allowing functions to be passed into the rendering pipeline as attributes of
Node
s…