1

If I run

(plist-get '(A  4  B  3) 'B)

I get 3 as expected. I understand that I must quote B, otherwise

(plist-get '(A  4  B  3) B)

causes an error:

elisp--eval-last-sexp: Symbol’s value as variable is void: B

However, I do not understand why these two versions work (even without quoting :B)

(plist-get '(:A  4  :B  3) ':B)  ;; works
(plist-get '(:A  4  :B  3) :B)   ;; also works !

Does : have a special meaning ?

2

1 Answer 1

1

They’re called keywords. They are a type of symbol that evaluates to themselves, so they don’t need to be quoted (as you discovered). Check out chapter 2.4.4 Symbol Type of the Emacs Lisp manual, which describes them.

   A symbol whose name starts with a colon (‘:’) is called a “keyword
symbol”.  These symbols automatically act as constants, and are normally
used only by comparing an unknown symbol with a few specific
alternatives.  *Note Constant Variables::.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.