Re: a noob question
From: Tayssir John Gabbour (tayss_temp2_at_yahoo.com)
Date: 01/24/05
- Next message: Bruce Stephens: "Re: a noob question"
- Previous message: lin8080: "Re: Pt. II - Continued"
- In reply to: Michael Beattie: "a noob question"
- Next in thread: Tayssir John Gabbour: "Re: a noob question"
- Reply: Tayssir John Gabbour: "Re: a noob question"
- Reply: Surendra Singhi: "Re: a noob question"
- Reply: Tayssir John Gabbour: "Re: a noob question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 23 Jan 2005 15:36:46 -0800
Michael Beattie wrote:
> Why is it that some macros or whatever have double parens around
> them? Like...
>
> (let ((x 2))) ; this has 2 parens around the x=2 assignment
>
> or
>
> (do ((i 0 (+ i 1))) ; there's 2 parens around the i=0 and the
increment
> ((> i 10) 'done) ; 2 parens around the "end" condition
> (print i))
>
> I guess part of the question is "what exactly is the template for
> the do or let macro?"
Good questiron. LET's syntax is:
let ({var | (var [init-form])}*) declaration* form* => result*
If we did away with having a single "var" without an initform, which is
probably sucky practice anyway, we could do without the multiple
parens:
. (let (blah 10
. foo 20
. bar 30)
. (+ blah foo bar))
I'm guessing the Ancients didn't think of it, or really liked tacitly
initting stuff to nil. I recall Paul Graham complaining about this once
while talking about Arc. And if you think about it, setf actually is
like this when you're setting multiple things at once.
. (defmacro let- ((&rest inits) &body body)
. `(let ,(loop for i on inits by #'cddr
. collect (list (first i) (second i)))
. ,@body))
At the prompt:
. CL-USER> (macroexpand '(let- (blah 10
. foo 20
. bar 30)
. (list blah foo bar)))
.
. (let ((blah 10)
. (foo 20)
. (bar 30))
. (list blah foo bar))
. t
MfG,
Tayssir
- Next message: Bruce Stephens: "Re: a noob question"
- Previous message: lin8080: "Re: Pt. II - Continued"
- In reply to: Michael Beattie: "a noob question"
- Next in thread: Tayssir John Gabbour: "Re: a noob question"
- Reply: Tayssir John Gabbour: "Re: a noob question"
- Reply: Surendra Singhi: "Re: a noob question"
- Reply: Tayssir John Gabbour: "Re: a noob question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|