4 ms·
A naive implementation has to do a ridiculous number of scope lookups, even before you get to anything else. Also instead of compile time macros, one has runti
by mst 6y ago
A naive implementation has to do a ridiculous number of scope lookups, even before you get to anything else.
Also instead of compile time macros, one has runtime fexprs, which means the equivalent of macro expansion happens every invocation.
However, one can have kernel style semantics with at least moderately reasonable performance by basically applying a combination of constant folding and expansion caching.
It's a bunch of extra effort though, and non-trivial to make work, though I'm currently experimenting myself with something where I'm willing to do that.
A key part is to be able to recognise fexprs that are 'really' just macros and pre-expand them and cache the expansion - without at least that you're screwed.
I'm also experimenting with what else I can cache given the principle that everything is a lexical environment.
I'm rather enjoying myself ... but understand the risks.