Why does Clojure have “keywords” in addition to “symbols”?

前端 未结 6 1820
暖寄归人
暖寄归人 2020-12-12 11:02

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\"

6条回答
  •  既然无缘
    2020-12-12 11:25

    :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

提交回复
热议问题