newLISP does dynamic binding inside of static isolated namespaces.
Personally I find dynamic binding more natural. I believe the current trend towards static binding is more a reflection of today's CS curriculum, than of the realities of programming in the real world of applications outside academia. I see static binding more as a fashion than something which is superior to dynamic binding. Both have their advantages and disadvantages.
For most users the fact of dynamic binding in newLISP is not an issue. But dynamic binding dictates a different programming style, avoiding non-local variables. In an example as yours it is still Ok, if you know how dynamic bindng behaves, because the functions involved are close to each other.
Bigger newLISP programs are typically organized in smaller modules inside contexts/namespaces. The overhead of the namespace mechanism is minimal and there is no speed disadvantage. Namespaces isolates modules from each other and can have state.
You also can use contexts/namespaces to create functions with state and with some special advantages as explained below.
Here is a small example also using the concept of
default functions in newLISP:
Code: Select all
(context 'gen)
(define (gen:gen x)
(if acc
(inc 'acc x)
(set 'acc x)))
(context MAIN)
(gen 1) => 1
(gen 1) => 2
(gen 2) => 4
(gen 3) => 7
In newLISP everything (data, functions, contexts, symbols) can be
serialized into an ASCII readable file. Imagine you have above example program and executed (gen 1) a few times. Simply by executing
you have saved the current state of your name space to a human readable file, which looks like this:
Code: Select all
(context 'gen)
(set 'acc 7)
(define (gen:gen x)
(if acc
(inc 'acc x)
(set 'acc x)))
(context 'MAIN)
Now exiting and restarting newLISP you can do a
and have the same state of your function 'gen' back. This is something not possible in a Scheme interpreter unless you save some special binary image format, or invent special language facilities to express the enclosed state of a lambda closure.
newLISP's load/save facility is frequently used for small databases, configuration files, etc.
Please explore newLISP a bit more, you have to
unlearn certain ways learned from Common LISP and Scheme, but gain a very agile powerful tool with more depth then suggested by it's small size.
These links from the newlisp.org site may also be useful for you:
http://newlisp.org/index.cgi?page=Diffe ... ther_LISPs
and about newLISP's unique automatic memory management:
http://newlisp.org/MemoryManagement.html
Lutz
ps: welcome to the newLISP community
ps: I will comment on your SSL questions in the other thread later