| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| I was doing some experimenting with MACROLET, just to figure out how it works a little better, but I can't get the following code to work. It only prints "Hello World!" once instead of 10 times. There's no specific goal for this code. I was just experimenting for learning purposes only. (macrolet ((with-ps-gensyms ((&rest names) &body body) `(let ,(loop for n in names collect `(,n (gensym))) ,@body)) (ntimes (n &rest body) `(with-ps-gensyms (g h) `(let ((,h ,,n)) (do ((,g 0 (+ ,g 1))) ((>= ,g ,h)) ,,@body))))) (ntimes 10 (format t "Hello World!~%"))) |
|
#2
| |||
| |||
| Tinkering a little, I've just discovered that it expands correctly by replacing ,,@body with ,',@body which seems logical of course yetit still requires one more evaluation step. In other words, it works only if I replace the invocation (ntimes 10 (format t "Hello World!~ %")) with (eval (ntimes 10 (format t "Hello World!~%"))) which is of course a ridiculous thing to have to do, so I'm still pretty much stuck, only a little closer maybe to the solution. rock69 wrote: > I was doing some experimenting with MACROLET, just to figure out how > it works a little better, but I can't get the following code to work. > It only prints "Hello World!" once instead of 10 times. There's no > specific goal for this code. I was just experimenting for learning > purposes only. > > (macrolet ((with-ps-gensyms ((&rest names) &body body) > `(let ,(loop for n in names collect `(,n (gensym))) > ,@body)) > (ntimes (n &rest body) > `(with-ps-gensyms (g h) > `(let ((,h ,,n)) > (do ((,g 0 (+ ,g 1))) > ((>= ,g ,h)) > ,,@body))))) > (ntimes 10 (format t "Hello World!~%"))) |
|
#3
| |||
| |||
| On Aug 21, 3:58*pm, rock69 <rocco.ro...@gmail.com> wrote: > Tinkering a little, I've just discovered that it expands correctly by > replacing ,,@body with ,',@body which seems logical of course yet> it still requires one more evaluation step. In other words, it works > only if I replace the invocation (ntimes 10 (format t "Hello World!~ > %")) with (eval (ntimes 10 (format t "Hello World!~%"))) which is of > course a ridiculous thing to have to do, so I'm still pretty much > stuck, only a little closer maybe to the solution. > > rock69 wrote: > > I was doing some experimenting with MACROLET, just to figure out how > > it works a little better, but I can't get the following code to work. > > It only prints "Hello World!" once instead of 10 times. There's no > > specific goal for this code. I was just experimenting for learning > > purposes only. > > > (macrolet ((with-ps-gensyms ((&rest names) &body body) > > * * * * * * * * * * * *`(let ,(loop for n in names collect `(,n (gensym))) > > * * * * * * * * * * * * * ,@body)) > > * * * (ntimes (n &rest body) > > * * * * * * * `(with-ps-gensyms (g h) > > * * * * * * * * * * * * * * * * `(let ((,h ,,n)) > > * * * * * * * * * * * * * * * * * *(do ((,g 0 (+ ,g 1))) > > * * * * * * * * * * * * * * * * * ** *((>= ,g ,h)) > > * * * * * * * * * * * * * * * * * ** *,,@body))))) > > * * *(ntimes 10 (format t "Hello World!~%"))) > > OK, I got it all wrong. It turns out I didn't need nested backquotes in the first place. This works fine: (defmacro ntimes (n &rest body) `(with-ps-gensyms (g h) (let ((,h ,n)) (do ((,g 0 (+ ,g 1))) ((>= ,g ,h)) ,@body)))) Looks like I've got some more studying to do ![]() Does anyone know where I can find some really extensive info on backquote syntax? I've seen the HyperSpec, On Lisp, and ANSI Common Lisp, but it still feels like something's missing. Mr. Pitman help, please. |
|
#4
| |||
| |||
| On Aug 21, 4:12*pm, rock69 <rocco.ro...@gmail.com> wrote: > On Aug 21, 3:58*pm, rock69 <rocco.ro...@gmail.com> wrote: > > > > > Tinkering a little, I've just discovered that it expands correctly by > > replacing ,,@body with ,',@body which seems logical of course yet> > it still requires one more evaluation step. In other words, it works > > only if I replace the invocation (ntimes 10 (format t "Hello World!~ > > %")) with (eval (ntimes 10 (format t "Hello World!~%"))) which is of > > course a ridiculous thing to have to do, so I'm still pretty much > > stuck, only a little closer maybe to the solution. > > > rock69 wrote: > > > I was doing some experimenting with MACROLET, just to figure out how > > > it works a little better, but I can't get the following code to work. > > > It only prints "Hello World!" once instead of 10 times. There's no > > > specific goal for this code. I was just experimenting for learning > > > purposes only. > > > > (macrolet ((with-ps-gensyms ((&rest names) &body body) > > > * * * * * * * * * * * *`(let ,(loop for n in names collect `(,n (gensym))) > > > * * * * * * * * * * * * * ,@body)) > > > * * * (ntimes (n &rest body) > > > * * * * * * * `(with-ps-gensyms (g h) > > > * * * * * * * * * * * * * * * * `(let((,h ,,n)) > > > * * * * * * * * * * * * * * * * * *(do ((,g 0 (+ ,g 1))) > > > * * * * * * * * * * * * * * * * * * * *((>= ,g ,h)) > > > * * * * * * * * * * * * * * * * * * * *,,@body))))) > > > * * *(ntimes 10 (format t "Hello World!~%"))) > > OK, I got it all wrong. It turns out I didn't need nested backquotes > in the first place. This works fine: > > (defmacro ntimes (n &rest body) > * * * * * * * * * *`(with-ps-gensyms (g h) > * * * * * * * * * * * * * * * * * * *(let ((,h ,n)) > * * * * * * * * * * * * * * * * * * * * (do ((,g 0 (+ ,g 1))) > * * * * * * * * * * * * * * * * * * * * * * ((>= ,g ,h)) > * * * * * * * * * * * * * * * * * * * * * * ,@body)))) > > Looks like I've got some more studying to do ![]() > > Does anyone know where I can find some really extensive info on > backquote syntax? I've seen the HyperSpec, On Lisp, and ANSI Common > Lisp, but it still feels like something's missing. Mr. Pitman help, > please. Oops, the correct code is the following, sorry ... (macrolet ((with-ps-gensyms ((&rest names) &body body) `(let ,(loop for n in names collect `(,n (gensym))) ,@body)) (ntimes (n &rest body) `(with-ps-gensyms (g h) (let ((,h ,n)) (do ((,g 0 (+ ,g 1))) ((>= ,g ,h)) ,@body))))) (ntimes 10 (format t "Hello World!~%"))) |
|
#5
| |||
| |||
| rock69 wrote: > On Aug 21, 3:58 pm, rock69 <rocco.ro...@gmail.com> wrote: > >>Tinkering a little, I've just discovered that it expands correctly by >>replacing ,,@body with ,',@body which seems logical of course yet>>it still requires one more evaluation step. In other words, it works >>only if I replace the invocation (ntimes 10 (format t "Hello World!~ >>%")) with (eval (ntimes 10 (format t "Hello World!~%"))) which is of >>course a ridiculous thing to have to do, so I'm still pretty much >>stuck, only a little closer maybe to the solution. >> >>rock69 wrote: >> >>>I was doing some experimenting with MACROLET, just to figure out how >>>it works a little better, but I can't get the following code to work. >>>It only prints "Hello World!" once instead of 10 times. There's no >>>specific goal for this code. I was just experimenting for learning >>>purposes only. >> >>>(macrolet ((with-ps-gensyms ((&rest names) &body body) >>> `(let ,(loop for n in names collect `(,n (gensym))) >>> ,@body)) >>> (ntimes (n &rest body) >>> `(with-ps-gensyms (g h) >>> `(let ((,h ,,n)) >>> (do ((,g 0 (+ ,g 1))) >>> ((>= ,g ,h)) >>> ,,@body))))) >>> (ntimes 10 (format t "Hello World!~%"))) >> >> > > OK, I got it all wrong. It turns out I didn't need nested backquotes > in the first place. This works fine: > > (defmacro ntimes (n &rest body) > `(with-ps-gensyms (g h) > (let ((,h ,n)) > (do ((,g 0 (+ ,g 1))) > ((>= ,g ,h)) > ,@body)))) > > Looks like I've got some more studying to do ![]() > > Does anyone know where I can find some really extensive info on > backquote syntax? I've seen the HyperSpec, On Lisp, and ANSI Common > Lisp, but it still feels like something's missing. Mr. Pitman help, > please. Do what I do, just keep adding and removing quotes and ticks and commas and moving them around at the same time until it works. This is where the monkeys really earn their bananas. Sometimes I break stuff out into a second macro just to keep my sanity. When it gets depressing, just remember, you could be trying to use Scheme to do macros. When you are ready to kill yourself, use F#. hth, kenny |
|
#6
| |||
| |||
| On Aug 21, 4:27*pm, Kenny <kentil...@gmail.com> wrote: > rock69 wrote: > > On Aug 21, 3:58 pm, rock69 <rocco.ro...@gmail.com> wrote: > > >>Tinkering a little, I've just discovered that it expands correctly by > >>replacing ,,@body with ,',@body which seems logical of course yet> >>it still requires one more evaluation step. In other words, it works > >>only if I replace the invocation (ntimes 10 (format t "Hello World!~ > >>%")) with (eval (ntimes 10 (format t "Hello World!~%"))) which is of > >>course a ridiculous thing to have to do, so I'm still pretty much > >>stuck, only a little closer maybe to the solution. > > >>rock69 wrote: > > >>>I was doing some experimenting with MACROLET, just to figure out how > >>>it works a little better, but I can't get the following code to work. > >>>It only prints "Hello World!" once instead of 10 times. There's no > >>>specific goal for this code. I was just experimenting for learning > >>>purposes only. > > >>>(macrolet ((with-ps-gensyms ((&rest names) &body body) > >>> * * * * * * * * * * * `(let ,(loop for n in names collect `(,n (gensym))) > >>> * * * * * * * * * * * * *,@body)) > >>> * * *(ntimes (n &rest body) > >>> * * * * * * *`(with-ps-gensyms (g h) > >>> * * * * * * * * * * * * * * * *`(let ((,h ,,n)) > >>> * * * * * * * * * * * * * * * * * (do ((,g 0 (+ ,g 1))) > >>> * * * * * * * * * * * * * * * * * * * ((>= ,g ,h)) > >>> * * * * * * * * * * * * * * * * * * * ,,@body))))) > >>> * * (ntimes 10 (format t "Hello World!~%"))) > > > OK, I got it all wrong. It turns out I didn't need nested backquotes > > in the first place. This works fine: > > > (defmacro ntimes (n &rest body) > > * * * * * * * * * *`(with-ps-gensyms (g h) > > * * * * * * * * * * * * * * * * * **(let ((,h ,n)) > > * * * * * * * * * * * * * * * * * ** * (do ((,g 0 (+ ,g 1))) > > * * * * * * * * * * * * * * * * * ** * * * ((>= ,g ,h)) > > * * * * * * * * * * * * * * * * * ** * * * ,@body)))) > > > Looks like I've got some more studying to do ![]() > > > Does anyone know where I can find some really extensive info on > > backquote syntax? I've seen the HyperSpec, On Lisp, and ANSI Common > > Lisp, but it still feels like something's missing. Mr. Pitman help, > > please. > > Do what I do, just keep adding and removing quotes and ticks and commas > and moving them around at the same time until it works. This is where > the monkeys really earn their bananas. Sometimes I break stuff out into > a second macro just to keep my sanity. When it gets depressing, just > remember, you could be trying to use Scheme to do macros. When you are > ready to kill yourself, use F#. > > hth, kenny Yeah, I guess it really is just a matter of trial and error. LikeGraham says, it's like trying to figure out a complex integral by just looking at it. F# no way! LOL |
|
#7
| |||
| |||
| On Aug 21, 5:02*pm, rock69 <rocco.ro...@gmail.com> wrote: > On Aug 21, 4:27*pm, Kenny <kentil...@gmail.com> wrote: > > > > > rock69 wrote: > > > On Aug 21, 3:58 pm, rock69 <rocco.ro...@gmail.com> wrote: > > > >>Tinkering a little, I've just discovered that it expands correctly by > > >>replacing ,,@body with ,',@body which seems logical of course yet> > >>it still requires one more evaluation step. In other words, it works > > >>only if I replace the invocation (ntimes 10 (format t "Hello World!~ > > >>%")) with (eval (ntimes 10 (format t "Hello World!~%"))) which is of > > >>course a ridiculous thing to have to do, so I'm still pretty much > > >>stuck, only a little closer maybe to the solution. > > > >>rock69 wrote: > > > >>>I was doing some experimenting with MACROLET, just to figure out how > > >>>it works a little better, but I can't get the following code to work.. > > >>>It only prints "Hello World!" once instead of 10 times. There's no > > >>>specific goal for this code. I was just experimenting for learning > > >>>purposes only. > > > >>>(macrolet ((with-ps-gensyms ((&rest names) &body body) > > >>> * * * * * * * * * * * `(let ,(loop for n in names collect `(,n (gensym))) > > >>> * * * * * * * * * * * * *,@body)) > > >>> * * *(ntimes (n &rest body) > > >>> * * * * * * *`(with-ps-gensyms (g h) > > >>> * * * * * * * * * * * * * * * *`(let ((,h ,,n)) > > >>> * * * * * * * * * * * * * * * * *(do ((,g 0 (+ ,g 1))) > > >>> * * * * * * * * * * * * * * * * ** * ((>= ,g ,h)) > > >>> * * * * * * * * * * * * * * * * ** * ,,@body))))) > > >>> * * (ntimes 10 (format t "Hello World!~%"))) > > > > OK, I got it all wrong. It turns out I didn't need nested backquotes > > > in the first place. This works fine: > > > > (defmacro ntimes (n &rest body) > > > * * * * * * * * * *`(with-ps-gensyms (g h) > > > * * * * * * * * * * * * * * * * * * *(let ((,h ,n)) > > > * * * * * * * * * * * * * * * * * * * * (do ((,g 0 (+ ,g 1))) > > > * * * * * * * * * * * * * * * * * * * * * * ((>= ,g ,h)) > > > * * * * * * * * * * * * * * * * * * * * * * ,@body)))) > > > > Looks like I've got some more studying to do ![]() > > > > Does anyone know where I can find some really extensive info on > > > backquote syntax? I've seen the HyperSpec, On Lisp, and ANSI Common > > > Lisp, but it still feels like something's missing. Mr. Pitman help, > > > please. > > > Do what I do, just keep adding and removing quotes and ticks and commas > > and moving them around at the same time until it works. This is where > > the monkeys really earn their bananas. Sometimes I break stuff out into > > a second macro just to keep my sanity. When it gets depressing, just > > remember, you could be trying to use Scheme to do macros. When you are > > ready to kill yourself, use F#. > > > hth, kenny > > Yeah, I guess it really is just a matter of trial and error. Like> Graham says, it's like trying to figure out a complex integral by just > looking at it. > > F# no way! LOL Now this REALLY puzzles me. Going back to the previous version and feeding it to SBCL this is what I get: > (macrolet ((with-ps-gensyms ((&rest names) &body body) `(let ,(loop for n in names collect `(,n (gensym))) ,@body)) (ntimes (n &rest body) `(with-ps-gensyms (g h) `(let ((,h ,',n)) (do ((,g 0 (+ ,g 1))) ((>= ,g ,h)) ,',@body))))) (ntimes 10 (format t "Hello World!~%"))) OUTPUT: (LET ((#:G605 10)) (DO ((#:G604 0 (+ #:G604 1))) ((>= #:G604 #:G605)) (FORMAT T "Hello World!~%"))) Like I said, it doesn't get evaluated, but the expansion appears to be correct. Why doesn't it continue and evaluate it instead of stopping at this point??? |
|
#8
| |||
| |||
| rock69 <rocco.rossi@gmail.com> writes: > Now this REALLY puzzles me. Going back to the previous version and > feeding it to SBCL this is what I get: > > > (macrolet ((with-ps-gensyms ((&rest names) &body body) > `(let ,(loop for n in names collect `(,n (gensym))) > ,@body)) > (ntimes (n &rest body) > `(with-ps-gensyms (g h) > `(let ((,h ,',n)) > (do ((,g 0 (+ ,g 1))) ^ ^ Um, you have two levels of (back)quoting going on. That is what is stopping the evaluation. You want to drop the backquote in front of the WITH-PS-GENSYMS invocation. You want that macro to be expanded as an aid to the generation of the macro-expansion of NTIMES. You don't want it to be part of that macroexpansion. What I'm not sure of (and am too lazy to check the Hyperspect to find out) is whether MACROLET works like FLET or LABELS as far as scope is concerned. You might need to use nested MACROLET forms if you can't use the first macro definition while doing the expansion of the second. > ((>= ,g ,h)) > ,',@body))))) > (ntimes 10 (format t "Hello World!~%"))) > OUTPUT: > > (LET ((#:G605 10)) > (DO ((#:G604 0 (+ #:G604 1))) > ((>= #:G604 #:G605)) > (FORMAT T "Hello World!~%"))) > > Like I said, it doesn't get evaluated, but the expansion appears to be > correct. Why doesn't it continue and evaluate it instead of stopping > at this point??? Well, when debugging things like this, it is often useful to make these be top-level macro definitions and then use MACROEXPAND and MACROEXPAND-1 on them. -- Thomas A. Russ, USC/Information Sciences Institute |
|
#9
| |||
| |||
| On Aug 21, 11:25*am, rock69 <rocco.ro...@gmail.com> wrote: > On Aug 21, 5:02*pm, rock69 <rocco.ro...@gmail.com> wrote: > > > > > > > On Aug 21, 4:27*pm, Kenny <kentil...@gmail.com> wrote: > > > > rock69 wrote: > > > > On Aug 21, 3:58 pm, rock69 <rocco.ro...@gmail.com> wrote: > > > > >>Tinkering a little, I've just discovered that it expands correctly by > > > >>replacing ,,@body with ,',@body which seems logical of course yet> > > >>it still requires one more evaluation step. In other words, it works > > > >>only if I replace the invocation (ntimes 10 (format t "Hello World!~ > > > >>%")) with (eval (ntimes 10 (format t "Hello World!~%"))) which is of > > > >>course a ridiculous thing to have to do, so I'm still pretty much > > > >>stuck, only a little closer maybe to the solution. > > > > >>rock69 wrote: > > > > >>>I was doing some experimenting with MACROLET, just to figure out how > > > >>>it works a little better, but I can't get the following code to work. > > > >>>It only prints "Hello World!" once instead of 10 times. There's no > > > >>>specific goal for this code. I was just experimenting for learning > > > >>>purposes only. > > > > >>>(macrolet ((with-ps-gensyms ((&rest names) &body body) > > > >>> * * * * * * * * * * * `(let ,(loop for n innames collect `(,n (gensym))) > > > >>> * * * * * * * * * * * * *,@body)) > > > >>> * * *(ntimes (n &rest body) > > > >>> * * * * * * *`(with-ps-gensyms (g h) > > > >>> * * * * * * * * * * * * * * * *`(let ((,h ,,n)) > > > >>> * * * * * * * * * * * * * * * * * (do ((,g 0 (+ ,g 1))) > > > >>> * * * * * * * * * * * * * * * * * * * ((>= ,g ,h)) > > > >>> * * * * * * * * * * * * * * * * * * * ,,@body))))) > > > >>> * * (ntimes 10 (format t "Hello World!~%"))) > > > > > OK, I got it all wrong. It turns out I didn't need nested backquotes > > > > in the first place. This works fine: > > > > > (defmacro ntimes (n &rest body) > > > > * * * * * * * * * *`(with-ps-gensyms (g h) > > > > * * * * * * * * * * * * * * * * ** *(let ((,h ,n)) > > > > * * * * * * * * * * * * * * * * ** * * (do ((,g 0 (+ ,g 1))) > > > > * * * * * * * * * * * * * * * * ** * * * * ((>= ,g ,h)) > > > > * * * * * * * * * * * * * * * * ** * * * * ,@body)))) > > > > > Looks like I've got some more studying to do ![]() > > > > > Does anyone know where I can find some really extensive info on > > > > backquote syntax? I've seen the HyperSpec, On Lisp, and ANSI Common > > > > Lisp, but it still feels like something's missing. Mr. Pitman help, > > > > please. > > > > Do what I do, just keep adding and removing quotes and ticks and commas > > > and moving them around at the same time until it works. This is where > > > the monkeys really earn their bananas. Sometimes I break stuff out into > > > a second macro just to keep my sanity. When it gets depressing, just > > > remember, you could be trying to use Scheme to do macros. When you are > > > ready to kill yourself, use F#. > > > > hth, kenny > > > Yeah, I guess it really is just a matter of trial and error. Like> > Graham says, it's like trying to figure out a complex integral by just > > looking at it. > > > F# no way! LOL > > Now this REALLY puzzles me. Going back to the previous version and > feeding it to SBCL this is what I get: > > > (macrolet ((with-ps-gensyms ((&rest names) &body body) > > * * `(let ,(loop for n in names collect `(,n (gensym))) > * * * *,@body)) > * *(ntimes (n &rest body) > * *`(with-ps-gensyms (g h) > * * *`(let ((,h ,',n)) > * * * *(do ((,g 0 (+ ,g 1))) > * *((>= ,g ,h)) > * *,',@body))))) > * (ntimes 10 (format t "Hello World!~%"))) > > OUTPUT: > > (LET ((#:G605 10)) > * (DO ((#:G604 0 (+ #:G604 1))) > * * * ((>= #:G604 #:G605)) > * * (FORMAT T "Hello World!~%"))) > > Like I said, it doesn't get evaluated, but the expansion appears to be > correct. Why doesn't it continue and evaluate it instead of stopping > at this point???- Hide quoted text - Actually what came out was evaluated, it's just that what came out was quoted. (macrolet ((with-ps-gensyms ((&rest names) &body body) `(let ,(loop for n in names collect `(,n (gensym))) ,@body)) (ntimes (n &rest body) `(with-ps-gensyms (g h) (let ((h ,n)) (do ((g 0 (+ g 1))) ((>= g h)) ,@body))))) (ntimes 10 (format t "Hello World!~%"))) ---- Geoff |
|
#10
| |||
| |||
| On Aug 21, 7:07*pm, Geoffrey Summerhayes <sumr...@gmail.com> wrote: > On Aug 21, 11:25*am, rock69 <rocco.ro...@gmail.com> wrote: > > > > > On Aug 21, 5:02*pm, rock69 <rocco.ro...@gmail.com> wrote: > > > > On Aug 21, 4:27*pm, Kenny <kentil...@gmail.com> wrote: > > > > > rock69 wrote: > > > > > On Aug 21, 3:58 pm, rock69 <rocco.ro...@gmail.com> wrote: > > > > > >>Tinkering a little, I've just discovered that it expands correctly by > > > > >>replacing ,,@body with ,',@body which seems logical of course yet> > > > >>it still requires one more evaluation step. In other words, it works > > > > >>only if I replace the invocation (ntimes 10 (format t "Hello World!~ > > > > >>%")) with (eval (ntimes 10 (format t "Hello World!~%"))) which isof > > > > >>course a ridiculous thing to have to do, so I'm still pretty much > > > > >>stuck, only a little closer maybe to the solution. > > > > > >>rock69 wrote: > > > > > >>>I was doing some experimenting with MACROLET, just to figure outhow > > > > >>>it works a little better, but I can't get the following code to work. > > > > >>>It only prints "Hello World!" once instead of 10 times. There's no > > > > >>>specific goal for this code. I was just experimenting for learning > > > > >>>purposes only. > > > > > >>>(macrolet ((with-ps-gensyms ((&rest names) &body body) > > > > >>> * * * * * * * * * * * `(let ,(loop for n in names collect `(,n (gensym))) > > > > >>> * * * * * * * * * * * * *,@body)) > > > > >>> * * *(ntimes (n &rest body) > > > > >>> * * * * * * *`(with-ps-gensyms (g h) > > > > >>> * * * * * * * * * * * * * * * *`(let ((,h ,,n)) > > > > >>> * * * * * * * * * * * * * * * ** (do ((,g 0 (+ ,g 1))) > > > > >>> * * * * * * * * * * * * * * * ** * * ((>= ,g ,h)) > > > > >>> * * * * * * * * * * * * * * * ** * * ,,@body))))) > > > > >>> * * (ntimes 10 (format t "Hello World!~%"))) > > > > > > OK, I got it all wrong. It turns out I didn't need nested backquotes > > > > > in the first place. This works fine: > > > > > > (defmacro ntimes (n &rest body) > > > > > * * * * * * * * * *`(with-ps-gensyms (g h) > > > > > * * * * * * * * * * * * * * * * * * *(let ((,h ,n)) > > > > > * * * * * * * * * * * * * * * * * * * * (do ((,g 0 (+ ,g 1))) > > > > > * * * * * * * * * * * * * * * * * * * * * * ((>= ,g ,h)) > > > > > * * * * * * * * * * * * * * * * * * * * * * ,@body)))) > > > > > > Looks like I've got some more studying to do ![]() > > > > > > Does anyone know where I can find some really extensive info on > > > > > backquote syntax? I've seen the HyperSpec, On Lisp, and ANSI Common > > > > > Lisp, but it still feels like something's missing. Mr. Pitman help, > > > > > please. > > > > > Do what I do, just keep adding and removing quotes and ticks and commas > > > > and moving them around at the same time until it works. This is where > > > > the monkeys really earn their bananas. Sometimes I break stuff out into > > > > a second macro just to keep my sanity. When it gets depressing, just > > > > remember, you could be trying to use Scheme to do macros. When you are > > > > ready to kill yourself, use F#. > > > > > hth, kenny > > > > Yeah, I guess it really is just a matter of trial and error. Like> > > Graham says, it's like trying to figure out a complex integral by just > > > looking at it. > > > > F# no way! LOL > > > Now this REALLY puzzles me. Going back to the previous version and > > feeding it to SBCL this is what I get: > > > > (macrolet ((with-ps-gensyms ((&rest names) &body body) > > > * * `(let ,(loop for n in names collect `(,n (gensym))) > > * * * *,@body)) > > * *(ntimes (n &rest body) > > * *`(with-ps-gensyms (g h) > > * * *`(let ((,h ,',n)) > > * * * *(do ((,g 0 (+ ,g 1))) > > * *((>= ,g ,h)) > > * *,',@body))))) > > * (ntimes 10 (format t "Hello World!~%"))) > > > OUTPUT: > > > (LET ((#:G605 10)) > > * (DO ((#:G604 0 (+ #:G604 1))) > > * * * ((>= #:G604 #:G605)) > > * * (FORMAT T "Hello World!~%"))) > > > Like I said, it doesn't get evaluated, but the expansion appears to be > > correct. Why doesn't it continue and evaluate it instead of stopping > > at this point???- Hide quoted text - > > Actually what came out was evaluated, it's just that what came > out was quoted. > > (macrolet ((with-ps-gensyms ((&rest names) &body body) > * * * * * * *`(let ,(loop for n in names collect `(,n (gensym))) > * * * * * * * * ,@body)) > * * * * * *(ntimes (n &rest body) > * * * * * * *`(with-ps-gensyms (g h) > * * * * * * * * * * * * * * * (let ((h ,n)) > * * * * * * * * * * * * * * * * *(do ((g 0 (+ g 1))) > * * * * * * * * * * * * * * * * * * *((>= g h)) > * * * * * * * * * * * * * * * * * * ,@body))))) > * (ntimes 10 (format t "Hello World!~%"))) > > ---- > Geoff OK Geoff, thanks. I see what you mean. |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.