On Dec 8, 12:05 pm, Aaron Cohen <aa...@assonance.org> wrote:
> On Wed, Dec 8, 2010 at 2:40 PM, javajosh <javaj...@gmail.com> 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.
>
> 1) quote is a special form, so it's probably a bad symbol to be
> experimenting with in this way, let's use "+" instead.
>
> 2) This is kind of funny, (quote +) returns a symbol, not a ref
> holding the function. When you invoke it, you're actually calling the
> invoke method of the Fn implentation of the Symbol class, whose
> behavior is to look itself up in the first parameter (intended to be a
> collection), similar to how keywords look themselves up.


That almost kinda sort makes sense to me. I'm not sure whether to be
pleased or scared.

> Once you get a symbol, if you want to actually call it the way you
> were originally, try "resolve" amongst probably other ways.
>
> user=> (resolve '+)
> #'clojure.core/+
>
> user=> ((resolve '+) 1 2)
> 3

Cool!

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