From: Caelan Burris on 10 Aug 2010 22:10 So for the definition (defmacro blah (x y) (+ x y)) X and Y are evaluated during evaluation of the expansion, not during the expansion itself?
From: Pascal J. Bourguignon on 10 Aug 2010 22:16 Caelan Burris <caelanburris(a)gmail.com> writes: > So for the definition > > (defmacro blah (x y) > (+ x y)) > > X and Y are evaluated during evaluation of the expansion, not during > the expansion itself? Yes. -- __Pascal Bourguignon__ http://www.informatimago.com/
From: Pascal J. Bourguignon on 10 Aug 2010 22:20 Caelan Burris <caelanburris(a)gmail.com> writes: > So for the definition > > (defmacro blah (x y) > (+ x y)) > > X and Y are evaluated during evaluation of the expansion, not during > the expansion itself? Or rather, X and Y ARE NOT evaluated, since it's a macro. CL-USER> (defmacro blah (x y) (print x) (print y) (+ x y)) BLAH CL-USER> (blah 1 2) 1 2 3 So far, so good, we gave 1 and 2, which can be argument to +, so the macro expansion is 3 (which is a form, and since 3 is self-evaluating, we get as result 3). But: CL-USER> (blah (+ 1 1) x) (+ 1 1) X +: #1=(+ 1 1) is not a number [Condition of type SIMPLE-TYPE-ERROR] ; Evaluation aborted. CL-USER> Here, the list (+ 1 1) is not a valid argument to + (which takes only numbers, not lists), and therefore we get an error. A symbol such as X cannot be an argument to + either, so we'd get an error too for it. -- __Pascal Bourguignon__ http://www.informatimago.com/
From: Caelan Burris on 10 Aug 2010 23:53 Thanks to all of you for your help. The bit about macro call arguments not actually being evaluated was what I had missed.
From: Barry Margolin on 11 Aug 2010 00:16 In article <4ecc0fff-127a-46bc-a406-f38efadff7eb(a)x21g2000yqa.googlegroups.com>, Caelan Burris <caelanburris(a)gmail.com> wrote: > Thanks to all of you for your help. The bit about macro call arguments > not actually being evaluated was what I had missed. Really? I don't see how that has anything to do with the difference between your FOO and BAR macros. If macro arguments were evaluated, you'd expect both of them to report an error, since IF has no value. -- Barry Margolin, barmar(a)alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group ***
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: macro and implicit symbol interning? Next: Getting there.... |