Code: Select all
> (setq a:n 1 b:n 2 c:n 3)
3
> (new a 'ac)
ac
> ac:n
1
> ; so far, so good.
> (new b 'bc c 'cc)
bc
> ; wait, something's amiss.
> cc:n
nil
> ; yep. but i bet 'bc was bound to the 'b context.
> bc:n
2
> yes.
Code: Select all
> (println (help 'dolist)) ~>
dolist
syntax: (dolist (sym list) body ...)
The expressions in body are evaluated for each element in list. The
variable in sym is set to each of the elements before evaluation of the
body expressions. The variable used as loop index is local and behaves
according to the rules of dynamic scoping.
example:
(set 'x 123)
(dolist (x '(a b c d e f g)) ; prints: abcdefg
(print x)) => g ; return value
; x is local in dolist
; x has still its old value outside the loop
x => 123 ; x has still its old value
This prints abcdefg in the console window. The value for x is
unchanged after execution of dolist because of x's local scope. The
return value of dolist is the result of last evaluated expression.
Note that removing elements from the list, i.e. using pop will cause
dolist to leave the loop after the removal of the element.
I sense that newLISP may be very close. To what and how close, I do not know. These are the more abstract qualities of a language, harder to put into words. Lutz would know best what these qualities may be. He seems to have made all the right choices so far, and -- barring its hostile takeover by a borg-like entity -- newLISP will continue to be the best LISP to do everyday programming in.
m i c h a e l