2 ms·
It would be nice if there was some mechanism --at least for dynamic languages-- where when a feature X (say, the new "let" keyword) is introduced in the compile
by batista 15y ago
It would be nice if there was some mechanism --at least for dynamic languages-- where when a feature X (say, the new "let" keyword) is introduced in the compiler, you can add some code that adds support for it at runtime. Maybe with some kind of name-mangling to avoid name clashes with existing variable names, etc.
Of course it would incur a performance penalty, and for some stuff it might also be infeasible, but there could be some low level package just for this purpose, that provided options to add new keywords, bytecodes, etc.
The end result would be something like (in mock-pyjs glory):
if __language__.has_not("let") import __Future__.Let".
This would enable faster iterations of the main language, while keeping backwards compatibility. Anyone knows if anything like this exists?
(Well, you can do sort of this kind of thing in Lisp. But has it ever been attempted in a C-like syntax?)
P.S My understanding is that Python does not do this, it just makes the __future__ imported modules optional in the previous version of the compiler, but they are still implemented in plain C along with the rest of CPython, no?
- JoshTriplett 15y agoPersonally, I'd love to see an implementation of ES.next as a static compiler. Much like CoffeeScript provides a JavaScript-like language that compiles to JavaScript, an ES.next compiler could compile ES.next JavaScript to cross-browser JavaScript.