Macros don’t permit local variables. In order to avoid a forest of spagetti in the EventGraph one would like to factor it into subroutines, however since some operations (latent actions) can’t be used in Functions, macros are the only alternative in such cases. Unfortunately, the lack of local variables means that can’t be done cleanly in many cases.
It seems the bytecode interpreter uses stack allocation (FMemory_Alloca). for the stack frame to hold local variables. Perhaps this is why latent actions are only permitted at the top level? Heap allocating such frames would make it easy to support proper continuations (and hence latent actions in functions).
So it seems there are two issues here w/r to allowing latent actions in functions:
Functions called from c++ are expected to return synchronously.
The call frames leading up to the call site of the latent action would have to be preserved (each with its local variables and program counter).
I can think of solutions to both which are relatively easy to implement, but the question is whether you’d be amenable to considering them. Or if I’m overlooking something please let me know.