Note that the doc on that page says:

Note that class names normally denote class objects, but are treated
> specially in certain special forms, e.g. . and new.
>

Basically, only a class makes sense as the first argument to new, and I
suspect new doesn't use the standard symbol resolution.

On Mon, 20 Aug 2018 at 01:03, <codelim...@gmail.com> wrote:

> I am trying to follow the rules for unqualified symbol resolution as
> listed at https://clojure.org/reference/evaluation
>
> According to those rules, if my symbol is mapped to a class name in the
> current namespace, then that should override any (hopefully, accidental)
> local bindings of the same symbol. But this does not seem to happen
> reliably in the current version (1.9.0) as shown below. The resolution
> seems to be inconsistent depending on how the symbol is used as you can see
> below.
>
> user=> (clojure-version)
>
> "1.9.0"
>
> user=> (deftype my-t [x])
>
> user.my-t
>
> user=>  ((fn [x]
>
> (let [my-t 1]
>
> (println "Now I resolve to the locally bound my-t =" my-t)
>
> (println "You can even pass me as arguments to functions:" (+ my-t x))
>
> (.-x (new my-t "Funnily enough, now I resolve to the class user.my-t"))))
> 3)
>
> Now I resolve to the locally bound my-t = 1
> You can even pass me as arguments to functions: 4
> "Funnily enough, now I resolve to the class user.my-t"
>
>
> Surely, such a resolution of a symbol alternatively to a local binding and
> a class name is inconsistent, and makes hard to read as well as being a
> potential source of bugs? Am I wrong to expect an error thrown at least
> when evaluating the expression (+ my-t x)?
>
> --
> 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