So this afternoon I started hacking away on that. The parser recognizes the syntax and sends off alerts to the parse analyzer, which currently ignores them; so there's obviously still some progress to be made there [grin]
On the back end, I'm about halfway done writing the support infrastructure for handling function signatures, which will be a major component to passing functions around. Once that is finished, I just need to write a function pointer system that actually passes the function references between calls on the stack. That should be trivial, as I already have a mechanism that does something similar for reference parameters.
The final piece then will be linking the parser front-end to the back-end on the VM, which is done via the parse analyzer. In brief, the idea is for the analyzer to set up the VM with the requisite metadata so that the running program can (A) pass functions as parameters cleanly and (B) do type validation on those parameters using function signatures.
Once all this is done, we'll see the following program running successfully in Epoch:
//// FCF.EPOCH//// Example of first-class functions and higher-order functions//entrypoint : () -> (){ operate(41, increment) operate(43, decrement)}increment : (integer(number)) -> (integer(result, 0)){ assign(result(add(number, 1)))}decrement : (integer(number)) -> (integer(result, 0)){ assign(result(subtract(number, 1)))}operate : (integer(number), function op : (integer)->(integer)) -> (){ debugwritestring(cast(string, op(number)))}
Work may or may not get in the way this week, so I have no idea how long it'll be before this is actually finished. Overall though adding higher-order function support has gone a lot more smoothly than I originally guessed.
Combined with some parser refactorings and a couple of minor tweaks to the analyzer, R5 should have a pretty healthy set of improvements.