Relating to your random thought, note that:
=> '[(+ 2 3) (+ 4 5)]
[(+ 2 3) (+ 4 5)]

Probably the only way to make sense out of this is to talk about how every
expression is first "read" then "evaluated".

You can interactively explore how things are "read" in Clojure with
read-string.

=> (read-string "(a b c)")
(a b c)

As far as I know, Clojure doesn't give you a whole lot of control over how
things print at the REPL.  Several things print out identically, so a
legitimate follow-up question to the above, is "What exactly is that data
structure that was printed out as (a b c)?"

We can probe at it a little bit:
=> (type *1)
clojure.lang.PersistentList
=> (type (first *2))
clojure.lang.Symbol

>From this, we can perhaps conclude that in order to construct such a data
structure manually, we would evaluate:

=> (list (symbol "a") (symbol "b") (symbol "c"))
(a b c)

Through this process, you can gradually learn the way that expressions
typed into the REPL are read in as data structures.
Taking some of your other examples:

hello
after being read, becomes the data that would be produced by evaluating
(symbol "hello")

(1 2 3)
after being read, becomes the data that would be produced by evaluating
(list 1 2 3)

[(+ 2 3) (+ 4 5)]
after being read, becomes the data that would be produced by evaluating
(vector (list (symbol "+") 2 3) (list (symbol "+") 4 5)))
Note, I'm ignoring here the details of namespaces, and the details of how
these numbers are internally represented as longs.

Once you understand this reading process, the next step is to understand
the rules of evaluation.

For example,

Symbols evaluate by looking up what's stored in the corresponding var.
Lists evaluate by evaluating all the elements of the list, and treating it
as a function application of the first element to the rest of the elements
as arguments.
Vectors evaluate to a vector of all the evaluated items.
Numbers evaluate to themselves.
Keywords evaluate to themselves.
Strings evaluate to themselves.

Then, the question is what happens with quote.

=> (read-string "'(a b c)")
(quote (a b c))

So we see that '(a b c) is read in as the data structure
(list (symbol "quote") (list (symbol "a") (symbol "b") (symbol "c")))

Now we know how quotes are read, but how do they evaluate?

With all this background, it is now easy to understand how quote
evaluates.  Very simply, quote returns whatever it is quoting,
unevaluated.  The effect of this is that quote gives you a mechanism to get
back the data structure as it was read, without evaluating it.

Summing all this up,

'(a b c)
is like a shortcut for
(read-string "(a b c)")



On Fri, Sep 12, 2014 at 10:54 AM, jvanderhyde <jamesvh...@hotmail.com>
wrote:

> Another random thought: What to you call this?
> [(+ 2 3) (+ 4 5)]
> It is an expression, but it is not a literal--I cannot say it "evaluates
> to itself."
>
> Sorry if I'm being pedantic. Maybe it doesn't matter. Terminology is
> important, though, when I'm trying to teach.
>
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to