Alex Rivera | Logout

Why does Clojure have "keywords" in addition to "symbols"?

Asked 2009-10-06T19:20:35.700
143

I have a passing knowledge of other Lisps (particularly Scheme) from way back. Recently I've been reading about Clojure. I see that it has both "symbols" and "keywords". Symbols I'm familiar with, but not with keywords.

Do other Lisps have keywords? How are keywords different from symbols other than having different notation (ie: colons)?

Edit
Report

2 Answers

6

Keywords are symbols that evaluate to themselves, so you don't have to remember to quote them.

answered 2009-10-06T19:25:38.030
5

:keywords are also treated specially by many of the collections, allowing for some really convenient syntax.

(:user-id (get-users-map))

is the same as

((get-users-map) :user-id)

this makes things just a little more flexable

answered 2009-10-06T21:35:48.470

Your Answer