There are 2 kinds of lisps based on the meaning of a symbol.
Symbols have structure "slots". The first kind of lisp has symbols with a "function slot" and a "value slot". The second kind of lisp has only the "value slot". This affects the meaning of a symbol when it is used in the first position of a list. In a lisp that has a function slot and a value slot you can set them independently. So consider We set the FUNCTION slot of A to the plus function (setf (symbol-fuction 'a) #'+) and we set the VALUE slot of A to be 3 (setf (symbol-value 'a) 3) So just typing A gives the value 3: a => 3 But using it as a function gives: (a a a) == (+ 3 3) ==> 6 since the FUNCTION slot of A is + and the VALUE slot is 3 In the second kind of lisp, with only the VALUE slot this will not work since there is only one place to put anything. There is also the second question of how the first slot of a list is evaluated. Does it only get evaluated once or does it continue to be evaluated until it gets a function? So ((quote +) 2 3) in a lisp that evaluates the first thing once becomes: (+ 2 3) but "+" is a symbol, not a function so you get an error. In a lisp that evaluates the first slot until it gets a function then ((quote +) 2 3) ==> (+ 2 3) ==> (<function +> 2 3) ==> 5 Tim Daly On 12/8/2010 2:40 PM, javajosh wrote:
I was looking at quote. user=> (quote 1) 1 user=> (quote) nil user=> (quote quote) quote user=> ((quote quote) 1) nil It's the last result that confuses me. I would have expected the result to be "1" - e.g. the same as (quote 1). I figured I'd try quote on something other than itself, and it just got stranger: user=> ((quote +) 1 2) 2 I would have expected 3.
-- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en