From dgou at mac.com Thu Sep 23 18:36:13 2004 From: dgou at mac.com (Douglas Philips) Date: Thu, 23 Sep 2004 14:36:13 -0400 Subject: [Small-cl-src-discuss] Re: [Small-cl-src] What would var+++ be in CL? In-Reply-To: References: Message-ID: <72245A1B-0D8F-11D9-8370-000393030214@mac.com> On Sep 23, 2004, at 11:05 AM, Ingvar wrote: > ;;; Possibly a tad naive, but... > (defmacro post-incf (form &optional (increment 1)) > (let ((value (gensym "POST-INCF"))) > `(let ((,value ,form)) > (prog1 ,value (setf ,form (+ ,value ,increment)))))) Actually, this came up on comp.lang.lisp and a few good versions were posted there. i'm accessing the net via a temp. connection (i'm on vacation), else I'd just search and give the pointer to the posts myself. (Peter Lewerin's message of "Tue, 28 Sep 2004 11:12:47 +0200") References: <6.0.1.1.0.20040928105942.01a69ec0@pop.swip.net> Message-ID: Peter Lewerin 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 From mb at bese.it Wed Sep 29 18:09:23 2004 From: mb at bese.it (marco) Date: Wed, 29 Sep 2004 20:09:23 +0200 Subject: [Small-cl-src-discuss] Re: [Small-cl-src] What would var+++ be in CL? In-Reply-To: <72245A1B-0D8F-11D9-8370-000393030214@mac.com> (Douglas Philips's message of "Thu, 23 Sep 2004 14:36:13 -0400") References: <72245A1B-0D8F-11D9-8370-000393030214@mac.com> Message-ID: Douglas Philips writes: > Actually, this came up on comp.lang.lisp and a few good versions were > posted there. > i'm accessing the net via a temp. connection (i'm on vacation), else > I'd just search and give the pointer to the posts myself. >