[Small-cl-src-discuss] Re: [Small-cl-src] with-carry

marco mb at bese.it
Wed Sep 29 17:54:53 UTC 2004


Peter Lewerin <peter.lewerin at swipnet.se> writes:

> #|
> 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)))
>                        , at body)))
>
> ;; (with-carry x ((+ 2 3) (* x 10)) (print x))
> ;; => 50
> ;; expands to: (LET* ((X (+ 2 3)) (X (* X 10))) (PRINT X))

this reminded me of:

http://groups.google.com/groups?selm=ahnk8t%247d5%241%40luna.vcn.bc.ca

-- 
-Marco
Ring the bells that still can ring.
Forget your perfect offering.
There is a crack in everything.
That's how the light gets in.
     -Leonard Cohen




More information about the Small-cl-src-discuss mailing list