3 ms·
This reminds me of how "macros" work in Factor, in a way. You don't avoid manually creating the s-expression (though Scheme and Dylan have a nice mechanism for
by microdan 19y ago
This reminds me of how "macros" work in Factor, in a way. You don't avoid manually creating the s-expression (though Scheme and Dylan have a nice mechanism for that), but there is a finer line between macros and regular functions. A macro is a function which takes a bunch of arguments and returns another function which takes no arguments and does the action of the macro. Basically, it's constant-folded at compiletime if possible. The runtime definition is memoized. For Factor's syntax, this kind of macro is practical for everything but new definition syntax and datastructure literals (neither of which this idea would work really well on, and which there is a different mechanism for). In general, a macro operates just like other words and can be quoted and executed like them.