[Top][All Lists]

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

RE: :name or 'name?

From: Drew Adams
Subject: RE: :name or 'name?
Date: Mon, 21 Jan 2013 13:07:09 -0800

> My question is that usual instead of quoting symbol use 
> "keyword symbol" which you don't need to quote...

It is not common, but it is not wrong.  In Emacs Lisp a keyword symbol is just a
symbol whose name starts with `:' and that evaluates to itself.

> So you can write:
>   (put :mylib-error 'error-message "Unknown mylib error")
> instead of:
>   (put 'mylib-error 'error-message "Unknown mylib error")

Yes, you can.  Whether you want to in any given context is up to you.

> So avoid quoting by special naming conventions...

No idea what you mean by that.

Yes, using `:' as the first char of a symbol name means that you do not need to
quote the symbol, since such a symbol always evaluates to itself.

However, :foo and 'foo act similarly only for ONE evaluation.  :foo evaluates to
itself over and over, no matter how many times you evaluate the result of
evaluation.  'foo evaluates to foo, not to 'foo, and evaluating that result,
foo, typically does NOT return foo.

Keyword symbols are constants - you cannot assign them a value different from
themselves.  But they are still symbols, so you can put values on their property

reply via email to

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