4 ms·
"It would be great if some these ideas would be massaged into other languages." Of course, this would be possible if they had macros!
by spacemanaki 16y ago
"It would be great if some these ideas would be massaged into other languages."
Of course, this would be possible if they had macros!
- silentbicycle 16y agoNot really. The first has to do with how variable scope is managed. The second involves exception handling, and if your language unwinds the stack while looking for a handler, it's usually already too late. The third has to do with how local variables are managed for functions defined at runtime - while you could rewrite code with macros to pass an implicit closure value array to the function at all points of use, it would be quite a bit less awkward to have it part of the language proper. Heck, it's not that unusual to have C functions that take a void * argument for "userdata"; the function/userdata combination is one way of representing closures when compiling to C.
- spacemanaki 16y agoYeah I was waiting for someone to call me on this. I thought it might not be possible but wasn't sure. Mostly it was cool to see a "unique features of Lisp" blog post which didn't even mention macros.
- qbg 16y agoI guess in theory you could do it using macros, but if the underlying language lacks certain features you end up with compiler-in-a-macro-style macros. I'm not sure you are really extending the language at that point...
- technomancy 16y agoElisp does this; it has no language-level lexical scope, but you can get it using the lexical-let macro. From a functionality perspective it works surprisingly well, but if you look at the macroexpansion you'll go blind.