Using the example from the define-macro description in the newLISP doc I wrote two identical test functions, apart from the name of the parameter:
Code Select
(define-macro (dolist-while)
(letex (var (args 0 0)
lst (args 0 1)
cnd (args 0 2)
body (cons 'begin (1 (args))))
(let (res)
(catch (dolist (var lst)
(if (set 'res cnd) body (throw res)))))))
(define (test1 a-list)
(dolist-while (x a-list (!= x 'd)) (println x)))
(define (test2 lst)
(dolist-while (x lst (!= x 'd)) (println x)))
(test1 '(a b c d e f))
(test2 '(a b c d e f))
here is the output
Code Select
newLISP v.10.3.3 on OSX IPv4/6 UTF-8, execute 'newlisp -h' for more info.
>
(lambda-macro ()
(letex (var (args 0 0) lst (args 0 1) cnd (args 0 2) body (cons 'begin (1 (args))))
(let (res)
(catch
(dolist (var lst)
(if (set 'res cnd)
body
(throw res)))))))
(lambda (a-list) (dolist-while (x a-list (!= x 'd)) (println x)))
(lambda (lst) (dolist-while (x lst (!= x 'd)) (println x)))
a
b
c
nil
ERR: list expected in function dolist : lst
called from user defined function dolist-while
called from user defined function test2
>