Re: Macros, declare, and locally
From: Kent M Pitman (pitman_at_nhplace.com)
Date: 03/10/05
- Next message: Pascal Bourguignon: "Re: [OT] PostLisp, a language experiment"
- Previous message: Kent M Pitman: "Re: One last chapter to review! Last chance! One-day only!"
- In reply to: Kalle Olavi Niemitalo: "Re: Macros, declare, and locally"
- Next in thread: Kalle Olavi Niemitalo: "Re: Macros, declare, and locally"
- Reply: Kalle Olavi Niemitalo: "Re: Macros, declare, and locally"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 10 Mar 2005 22:39:22 GMT
Kalle Olavi Niemitalo <kon@iki.fi> writes:
> Damien Kick <dkick1@email.mot.com> writes:
>
> > But if one can write a macro which expands into a LOCALLY form, does
> > this not mean that one must continue to call MACROEXPAND to find the
> > end of the declarations?
>
> No, it doesn't. A LOCALLY form terminates the list of local
> declarations, just like any other form would
True, but not the key issue.
(defun foo (x)
(declare (special x))
x) ; <-- this x is special
(defun foo (x)
(locally (declare (special x)))
x) <-- this x is NOT special
The scope of a locally is only its body. That is,
(LOCALLY (DECLARE (SPECIAL X))
... this part is where X is special ...)
so
(defun foo (x)
(locally (declare (special x))
;; There's nothing in this LOCALLY body
) ;; <-- this closes the body of LOCALLY
;; This isn't in the LOCALLY body, which is now closed.
x)
So you're right that LOCALLY stops the list of declarations at the
top of FOO, but the reason is that it's an exectuable form. Indeed,
in many implementations:
(LOCALLY decls . forms)
expands into
(LET () decls . forms)
- Next message: Pascal Bourguignon: "Re: [OT] PostLisp, a language experiment"
- Previous message: Kent M Pitman: "Re: One last chapter to review! Last chance! One-day only!"
- In reply to: Kalle Olavi Niemitalo: "Re: Macros, declare, and locally"
- Next in thread: Kalle Olavi Niemitalo: "Re: Macros, declare, and locally"
- Reply: Kalle Olavi Niemitalo: "Re: Macros, declare, and locally"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|