
28 Sep
2004
28 Sep
'04
9:12 a.m.
#| In a reply to me in c.l.l., Adam Warner suggested a control structure for the cases when a computation is made in stages, with the result of each stage used somewhere in the next stage. The following is basically his code; I added a SYMBOL-MACROLET wrapper to be able to name the carry-over variable. See c.l.l. thread "Which style do you prefer?" |# (defmacro with-carry (c stages &body body) (symbol-macrolet ((_ c)) `(let* (,@(loop for item in stages collect (list _ item))) ,@body))) ;; (with-carry x ((+ 2 3) (* x 10)) (print x)) ;; => 50 ;; expands to: (LET* ((X (+ 2 3)) (X (* X 10))) (PRINT X))
7585
Age (days ago)
7585
Last active (days ago)
0 comments
1 participants
participants (1)
-
Peter Lewerin