Page 1 of 1

development version newLISP 8.8.6

Posted: Mon May 01, 2006 4:32 pm
by Lutz
• optional break condition in 'for, 'dolist' and 'dotimes'
• new 'letex' combines let and macro expansion
• bug fixes and doc additions/changes

files and change notes: http://newlisp.org/downloads/development/

Lutz

Posted: Mon May 01, 2006 7:24 pm
by rickyboy
I was looking at the manual for the 'letex' documentation. It says:

"The last example shows how 'letex' can be combined with 'define-macro' to do variable expansion of macro variables into an expression to be evaluated:

Code: Select all

(define-macro (dolist-while)
   (letex (var ((args) 0 0)
           lst ((args) 0 1) 
           cnd ((args) 0 2) 
           body ((args) -1))
       (catch (dolist (var lst)
           (if (set 'res cnd) body (throw res) )))))

> (dolist-while (x '(a b c d e f) (!= x 'd)) (println x))
a
b
c
nil
'dolist-while' loops through a list while the condition is true."

But, it will not work for a 'body' with more than one form:

Code: Select all

> (dolist-while (x '(a b c d e f) (!= x 'd)) (print "x=") (println x))
a
b
c
nil
This one seems to work for multi-form 'body's.

Code: Select all

(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)))))))

> (dolist-while (x '(a b c d e f) (!= x 'd)) (print "x=") (println x))
x=a
x=b
x=c
nil
Thank you, Lutz, for providing this functionality. --Ricky

Posted: Mon May 01, 2006 8:42 pm
by Lutz
Thanks Rick for catching this, it will be corrected in the manual.

Lutz

ps: BTW 'letex' will do expansion on multiple expression bodies

Posted: Mon May 15, 2006 7:39 pm
by newdep
Yesssssss ..Thanks Lutz!!
you added some very nice extras in the last 2 releases!! great..

Posted: Mon May 15, 2006 9:11 pm
by Lutz
... and more to come, try newLISP's new syntax highlighting service here:

http://newlisp.org/code/highlight.html

you can try it with Pjot's url: http://www.turtle.dds.nl/newlisp/speaker.lsp

Lutz

ps: read more about it here: http://newlisp.org/index.cgi?page=News