How can I generate keyword symbols like :foo ?
make-symbol does not work:
CL-USER> (make-symbol "foo")
#:|foo|
CL-USER> (make-symbol ":foo")
#:|:foo|
What I want is:
CL-USER> (generate-keyword-symbol ":foo")
:foo
Any suggestions how to achieve that?
(if macro or function plays no role)
Andr�
--
Andr� Thieme wrote:
> How can I generate keyword symbols like :foo ?
>
> make-symbol does not work:
> CL-USER> (make-symbol "foo")
> #:|foo|
> CL-USER> (make-symbol ":foo")
> #:|:foo|
>
> What I want is:
> CL-USER> (generate-keyword-symbol ":foo")
> :foo
>
> Any suggestions how to achieve that?
> (if macro or function plays no role)
(intern "foo" "KEYWORD") ==> :|foo|
(MAKE-SYMBOL creates uninterned symbols.)
Paul
Andr� Thieme wrote:
>
> What I want is:
> CL-USER> (generate-keyword-symbol ":foo")
> :foo
>
> Any suggestions how to achieve that?
> (if macro or function plays no role)
The problem you are running into is simple. From the CLHS :
"make-symbol creates and returns a fresh, uninterned symbol whose name
is the given name."
the important part to note here is "uninterned", meaning the symbol is
not "INTERN"'d in any package.
Keyword symbols are just normal symbols that are interned in the KEYWORD
package.. because of this, there is no way to create an uninterned
KEYWORD symbol (makes sense right?).
try something like this, after reading the relevant parts of the hyperspec :
(defun generate-keyword-symbol (string)
(intern (string-upcase string) 'keyword))
CL-USER> (generate-keyword-symbol "foo")
:FOO
:EXTERNAL
INTERN is what you need, not make-symbol.
drewc
>
>
> Andr�
> --
--
Drew Crampsie
drewc at tech dot coop
"Never mind the bollocks -- here's the sexp's tools."
-- Karl A. Krueger on comp.lang.lisp