5 ms·
It can be ineffecient to generate and pass environments around, but it doesn't have to be, nor does it have to be a hack. Compiling with continuations [0] give
by shakna 10y ago
It can be ineffecient to generate and pass environments around, but it doesn't have to be, nor does it have to be a hack.
Compiling with continuations [0] gives you a very efficient output, and a lexical environment that is easily modified, and intuitive to exist. Combine that with Cheney on the MTA, and first class environments are no more costly than a lambda.
It is also possible to compile the initial environment [1], which makes it simpler to JIT any functions later linked to the structure.
I'm not sure why you think a compiler has to throw away the environment, its certainly not what MIT Scheme does, as environments are special forms that persist as you go down and up the stack. [2]
[0] http://matt.might.net/articles/cps-conversion/ http://matt.might.net/articles/cps-conversion/
[1] https://github.com/gambit/gambit/commit/09284455ae7c7e8dff4a71b8a60e5315e04fbe61 https://github.com/gambit/gambit/commit/09284455ae7c7e8dff4a...
[2] https://groups.csail.mit.edu/mac/ftpdir/scheme-7.4/doc-html/scheme_14.html https://groups.csail.mit.edu/mac/ftpdir/scheme-7.4/doc-html/...