4 ms·
OK, 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)
by itistoday 17y ago
OK, 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.