Prev: emacs manual problem
Next: 3 questions about arrays
From: Spiros Bousbouras on 2 Dec 2009 17:02 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 2 Dec 2009 18:11 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 2 Dec 2009 19:05 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 3 Dec 2009 03:42 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 3 Dec 2009 07:44
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 |