(show&tell) The Many or the Few
Posted: Wed May 03, 2006 6:17 am
Lutz recently reminded me that constant can take multiple pairs of arguments. At the newLISP prompt the other day, I wondered if new did this, as well. So, rather than do the sensible thing and refer to the manual or one of the aforementioned introductions (see 8th post down), I just tried it . . .
So, only one argument pair as with define. This makes perfect sense with define, but does it with new? This made me realize I needed some way to intuit, or at least find out, what a function is capable of doing. Of course, the manual clears all these matters right up. So what might be helpful is a function that returns a string of the manual's definition for that symbol (symbols?):
This shortens the path to the information needed to freely experiment with the language. And experimentation is a powerful way to quickly learn how to do almost anything.
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
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