4 ms·
Sorry, by "troll" I meant someone who spreads misinformation, whether deliberately or unknowingly through ignorance. Perhaps I'm misusing the word, if so, my ap
by itistoday 17y ago
Sorry, by "troll" I meant someone who spreads misinformation, whether deliberately or unknowingly through ignorance. Perhaps I'm misusing the word, if so, my apologies.
A great deal has already been written about how dynamic scope is a Bad Thing.
What most people don't like about dynamic scope has to do with its use in compiled languages. newLISP isn't compiled and so many of those criticisms aren't applicable.
Dynamic scope because makes newLISP fast (lexical scope adds a great deal of overhead). newLISP also doesn't need lexical scope because it has ways of doing lexical scope on a need-to-use basis (see the 'letex' and 'expand' functions). Most of the time you don't need to worry about it, and oftentimes dynamic scope is a nice thing to have, too.
So please, do dive into the issue of scope, it's an important one, but do so fully informed about it. At least with regards to newLISP, it's certainly not a show stopper.
- abstractbill 17y agoMy issues (and I think most peoples' issues) with dynamic scope have nothing to do with being compiled or interpreted. From wikipedia (http://en.wikipedia.org/wiki/Scope_%28programming%29#Dynamic_scoping http://en.wikipedia.org/wiki/Scope_%28programming%29#Dynamic...): "However, this benefit relies on careful documentation of all variables used this way as well as on careful avoidance of assumptions about a variable's behavior, and does not provide any mechanism to detect interference between different parts of a program. As such, dynamic scoping can be dangerous and almost no modern languages use it."
- itistoday 17y agoOK, but that paragraph doesn't provide a practical example of what it's talking about, so I'll provide one here: (define (my-unpredictable-func) (println a)) In that function the value of the symbol 'a' will change depending on the context the function is called in. This is called an "unbounded symbol" (or something along those lines), and it is the thing that paragraph is referring to. It is true that it is not safe to write code like this, and so most newLISP code doesn't do this. The proper way to write the function in newLISP is like so: (define (my-predictable-func a) (println a)) Here it is plain and obvious what the value of 'a' will be: whatever is passed into the function. This is how most newLISP code is written, and it works, and it's safe, and it's fast. If newLISP used lexical scope you would be complaining about how slow it was. In very rare circumstances, you may need some lexical construct, in which case you have the functions 'letex' and 'expand' available to you. From this example you can see that this isn't a "show stopper" but something to simply be aware of. Sortof how dereferencing NULL pointers in C is a possibility, but not a show stopper.
- KazimirMajorinc 17y agoThis problem exists, but it is equivalent to problems Common Lisp programmer has to face if he writes macros, and solutions are similar. In CL it is solved with gensyms, and Scheme hygienic macros automatised that. Similar approaches are possible - and practiced - in Newlisp.