4 ms·
Dynamic scope is a decrease in expressive power. You don't get closures.
by pg 17y ago
Dynamic scope is a decrease in expressive power. You don't get closures.
- plinkplonk 17y agoPG on newLisp a long time ago "I took a quick look at it. It looked to me as if the way you're supposed to avoid variable capture is to use variables with unusual names. Is this really the plan? What about expansions that occur within expansions?" http://lambda-the-ultimate.org/node/257#comment-1889 http://lambda-the-ultimate.org/node/257#comment-1889
- KazimirMajorinc 17y agoThere are few ways out of that: 1. use of "contexts" i.e. Newlisp namespaces 2. use of same approach as in CL or Scheme macros. In CL it is automatic generation of unusual names, gensyms, in Scheme it is even more automatic "hygiene". Both of these approaches are available in Newlisp as well. One can check my blog post at: http://kazimirmajorinc.blogspot.com/2009/12/symbols-as-sexprs.html http://kazimirmajorinc.blogspot.com/2009/12/symbols-as-sexpr... It is not simple reading if one didn't used dynamic scope, but essentially it is how one can write hygienic fexprs (Newlisp macros are actually fexprs). 3. use of some "OO" additions. I am bit of OO sceptic, but for those who are not, there are at least two OO systems for Newlisp. 3.1. Official FOOP system, still in development http://newlispfanclub.alh.net/forum/viewtopic.php?f=2&t=3408&start=0 http://newlispfanclub.alh.net/forum/viewtopic.php?f=2&t=... 3.2. Greg's OO system http://www.taoeffect.com/blog/2009/12/introducing-objective-newlisp/ http://www.taoeffect.com/blog/2009/12/introducing-objective-...
- KazimirMajorinc 17y agoClosures are the functions with "private" data preserving values between two calls of the same function. It is not impossible with dynamic scope - but problem is again accidental name clash. As it is the same problem as with macros - I guess it can be solved on similar way - using functions with generated unusual and unique names of variables. On the other side, with dynamic scope, functions are as expressive (or almost) as macros and they are the first class values. For example, one can implement "if" as a function. http://kazimirmajorinc.blogspot.com/2009/01/two-definitions-of-if-function.html http://kazimirmajorinc.blogspot.com/2009/01/two-definitions-...