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 ?

Drew
  • 75,699
  • 9
  • 109
  • 225
Picaud Vincent
  • 1,158
  • 8
  • 20
  • 1
    See e.g [here](https://emacs.stackexchange.com/questions/59783/how-to-use-keyword-symbols-in-emacs-lisp) and [here](https://emacs.stackexchange.com/questions/12142/use-of-keyword-symbols-in-property-lists). – NickD Feb 03 '23 at 15:28
  • https://emacs.stackexchange.com/tags/elisp/info – Drew Feb 03 '23 at 16:36

1 Answers1

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::.
db48x
  • 15,741
  • 1
  • 19
  • 23