I'm trying to understand how to utilize the contexts of newlisp to implement various lexical bound idioms, for instance returning closures. Take this CL code for example:
Code Select
(defun make-multiplier (x) (lambda (y) (* x y))
make-multiplier is a generator of multiplier functions. It can generate as many functions as I want, each with its own internal data. For example:
Code Select
(setq doubler (make-multipler 2))
(funcall doubler 13)
Produces 26.
And then:
Code Select
(setq tripler (make-multipler 3))
(funcall tripler 13)
Produces 39.
How can I do it in newlisp ?
Thanks in advance