Tassilo Horn <tass...@member.fsf.org> writes:

>> As an aside, when playing around with quoting and unquoting, I
>> noticed that the result of ('+ 3 5) is 5. I'm not sure what I would
>> have expected (maybe an error?) but it wasn't the third item of the
>> list.  Is there any reason for this?
>
> Symbol implements AFn and can thus be invoked.  The implementations just
> call RT.get() which is a lookup for associatives.  So
>
>   ('+ 1) == (get '+ 1)
>
> and
>
>   ('+ 1 :not-found) == (get '+ 1 :not-found)
>
> Since Symbols are nothing associative, you'll always get nil in the
> former case and whatever you gave as "not-found" value in the latter
> case.
>
> Well, that explains your observation, but I have no clue how that should
> make sense...

Argh, I've read the code wrongly.  The impl in Symbol calls RT.get(obj,
this), not RT.get(this, obj), so that's why symbols can lookup
themselves in maps.

  ('foo {'foo 1}) ==> 1
  ('foo {'foo2 1} :nope) ==> :nope

Bye,
Tassilo

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