On Sep 26, 2010, at 10:42 AM, Steven E. Harris wrote:

> ataggart <alex.tagg...@gmail.com> writes:
> 
>> Vectors also permit evaluation of the literal collection's elements:
>> 
>> user=> [(+ 1 2) (+ 3 4)]
>> [3 7]
>> user=> '((+ 1 2) (+ 3 4))
>> ((+ 1 2) (+ 3 4))
> 
> That's a false distinction. You used `quote' rather than
> `list'. Macroexpand your form to see:
> 
> ,----
> | user> (quote ((+ 1 2) (+ 3 4)))
> | ((+ 1 2) (+ 3 4))
> `----
> 

Umm, kind of...The single quote is a macro character not a real macro. 
Therefore it's not subject to macroexpansion as macros are. Unfortunately the 
Clojure reader normally conspires against you to hide what's really going on. 
The reader silently converts 'pung to (quote pung) prior to evaluation, so you 
have to come at it in a roundabout way:
(read-string "'((+ 1 2) (+ 3 4))")  => (quote ((+ 1 2) (+ 3 4)))
(count (read-string "'((+ 1 2) (+ 3 4))")) => 2
(class (read-string "'((+ 1 2) (+ 3 4))")) => clojure.lang.Cons
(first (read-string "'((+ 1 2) (+ 3 4))")) => quote

At least the Clojure printer is cooperating here. In Common Lisp the printer 
helps hide QUOTE too in the first line here:
? (read-from-string "'(+ 1 2)")
'(+ 1 2)
8
? (first (read-from-string "'(+ 1 2)"))
QUOTE
? (length (read-from-string "'(+ 1 2)"))
2

Have all good days,
David Sletten




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

Reply via email to