From: Peter Keller on 13 Apr 2010 22:36 Hello, Is it possible to have a macro generate a keyword? As in (defmacro foo (thing) `(list :,thing)) Obviously, that doesn't work. I need this because the keyword is being defined in a package via a macro and I'd like it to be available to the users of the package. Thanks. -pete
From: Rob Warnock on 13 Apr 2010 23:38 Peter Keller <psilord(a)merlin.cs.wisc.edu> wrote: +--------------- | Is it possible to have a macro generate a keyword? +--------------- Sure. +--------------- | As in | (defmacro foo (thing) | `(list :,thing)) | | Obviously, that doesn't work. I need this because the keyword is being | defined in a package via a macro and I'd like it to be available to the | users of the package. +--------------- How about this? > (defmacro foo (thing) `(list ,(intern (string thing) :keyword))) FOO > (foo bar) (:BAR) > -Rob ----- Rob Warnock <rpw3(a)rpw3.org> 627 26th Avenue <URL:http://rpw3.org/> San Mateo, CA 94403 (650)572-2607
From: Peter Keller on 14 Apr 2010 09:31 Rob Warnock <rpw3(a)rpw3.org> wrote: > Peter Keller <psilord(a)merlin.cs.wisc.edu> wrote: > +--------------- > | As in > | (defmacro foo (thing) > | `(list :,thing)) > | > | Obviously, that doesn't work. I need this because the keyword is being > | defined in a package via a macro and I'd like it to be available to the > | users of the package. > +--------------- > > How about this? > > > (defmacro foo (thing) > `(list ,(intern (string thing) :keyword))) > > FOO > > (foo bar) > > (:BAR) > > Ooh! That looks perfect! Thank you! -pete
|
Pages: 1 Prev: Preliminary analysis of existing ASDF practices Next: problem with read-sequence |