[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: keywordp & :killing-the-cat

From: Drew Adams
Subject: RE: keywordp & :killing-the-cat
Date: Sat, 5 Sep 2009 14:14:46 -0700

> (keywordp :killing-the-cat-with-epr) ;=> t
> (unintern :killing-the-cat-with-epr) ;=> t
> (mapatoms (lambda (x)
>           (when (eq x :killing-the-cat-with-epr)
>               (prin1 `(found ,x))))
>                 obarray)

Evaluating (actually, Lisp reading) that sexp creates and interns a symbol

Try this instead:

(mapatoms (lambda (x)
              (when (string= (symbol-name x)
                  (prin1 `(found ,x))))

Replace ":killing-the-cat-with-epr" by the name of an existing symbol, e.g.
"forward-char", to see the difference.

> how does one use keywordp to test if a (possibly
> non-existent) keyword is interned without interning it?

You don't use keywordp for that. keywordp:

 Return t if OBJECT is a keyword.
 This means that it is a symbol with a print name beginning with `:'
 interned in the initial obarray.

IOW, keywordp returns non-nil only for an interned symbol (whose print name
starts with `:').

If you want to check whether a symbol is interned, use `intern-soft':

(intern-soft ":killing-the-cat-with-epr") -> nil
(intern-soft "forward-char") -> forward-char

reply via email to

[Prev in Thread] Current Thread [Next in Thread]