为什么Clojure Spels使用带引号的符号而不是关键字?

fad*_*bee 1 symbols clojure quote

为什么http://www.lisperati.com/clojure-spels/data.html使用带引号的符号而不是关键字?

(def objects '(whiskey-bottle bucket frog chain))

(def game-map (hash-map
   'living-room '((you are in the living room
                   of a wizards house - there is a wizard
                   snoring loudly on the couch -)
                  (west door garden)
                  (upstairs stairway attic))
   'garden '((you are in a beautiful garden -
              there is a well in front of you -)
             (east door living-room))
   'attic '((you are in the attic of the
             wizards house - there is a giant
             welding torch in the corner -)
            (downstairs stairway living-room))))

(def object-locations (hash-map
                       'whiskey-bottle 'living-room
                       'bucket 'living-room
                       'chain 'garden
                       'frog 'garden))

(def location 'living-room)

(defn describe-location [location game-map]
  (first (location game-map)))
Run Code Online (Sandbox Code Playgroud)

我改变了'living-room:living-room所有地方和它的工作.

我对Clojure很新 - 有什么意义'something,什么时候:something可以使用?

(我理解引用的作用 - 我想知道何时使用带引号的符号而不是关键字.)

Dav*_*ood 6

LispCasting SPEL原始版本是为Common Lisp编写的.虽然CL也有关键字(即),但作者选择使用带引号的符号列表.这捕获了Lisp的魔力,并且"代码作为数据"的概念 - 一个符号,在评估时,可以表示一个值,如一个函数,但也可以代表一个值本身,这是一个很酷的关于Lisp的事情.:foo

这只是我的印象,但是当作者为Clojure 翻译Casting SPEL时,我相信他决定仍然使用符号来表示数据(即使在Clojure中使用关键字和字符串会更加惯用)以保持完好无损关于Lisp的基础消息,能够将代码用作数据和数据作为代码.