From: Spiros Bousbouras on
Let's say I'm writing a macro which accepts declarations like do. Let's
say argument a to the macro may or may not be a declaration. Is this
the right way to check ?

(if (and (consp a) (eq (car a) 'declare))
; It's a declaration
; It isn't )

--
A mouse is a device used to point at the xterm you want to type in.
A.S.R.
From: Tim Bradshaw on
On 2009-12-02 22:02:48 +0000, Spiros Bousbouras <spibou(a)gmail.com> said:

> Let's say I'm writing a macro which accepts declarations like do. Let's
> say argument a to the macro may or may not be a declaration. Is this
> the right way to check ?
>
> (if (and (consp a) (eq (car a) 'declare))
> ; It's a declaration
> ; It isn't )

I think so. Remember you can have lots of declarations so you have to
walk down the body of the macro until you get to something that is not
DECLARE form.

From: Pascal J. Bourguignon on
Spiros Bousbouras <spibou(a)gmail.com> writes:

> Let's say I'm writing a macro which accepts declarations like do. Let's
> say argument a to the macro may or may not be a declaration. Is this
> the right way to check ?
>
> (if (and (consp a) (eq (car a) 'declare))
> ; It's a declaration
> ; It isn't )

Of course.
That's what macros do, they process code, and declarations are code.


--
__Pascal Bourguignon__
From: Thomas F. Burdick on
On Dec 3, 12:11 am, Tim Bradshaw <t...(a)cley.com> wrote:
> On 2009-12-02 22:02:48 +0000, Spiros Bousbouras <spi...(a)gmail.com> said:
>
> > Let's say I'm writing a macro which accepts declarations like do. Let's
> > say argument a to the macro may or may not be a declaration. Is this
> > the right way to check ?
>
> > (if (and (consp a) (eq (car a) 'declare))
> >     ; It's a declaration
> >     ; It isn't )
>
> I think so.  Remember you can have lots of declarations so you have to
> walk down the body of the macro until you get to something that is not  
> DECLARE form.

It's to bad that PARSE-BODY isn't in the spec. Not the least because
every implementation seems to have such a function, although not all
export it as interface.
From: Willem Broekema on
On Dec 2, 11:02 pm, Spiros Bousbouras <spi...(a)gmail.com> wrote:
> Let's say I'm writing a macro which accepts declarations like do. Let's
> say argument a to the macro may or may not be a declaration. Is this
> the right way to check ?

There's a library by Tobias C. Rittweiler. I have not used it yet but
its functionality seems quite extensive. It has "declaration-
env.affected-variables" for example:

http://common-lisp.net/project/parse-declarations/

- Willem
 |  Next  |  Last
Pages: 1 2
Prev: emacs manual problem
Next: 3 questions about arrays