This works fine:

user/ (read-string "#=(java.lang.Float. \"5\")")
5.0

However, these two cases fail:

user/ (read-string "#=(.toCharArray \"foo\")")
java.lang.Exception: Can't resolve .toCharArray

user/ (read-string "#=(java.lang.Enum/valueOf java.lang.Thread$State  
\"NEW\")")
java.lang.ClassCastException

In the first case, it looks like the dotted method invocation isn't  
being expanded into the (. obj (methodname)) form, so a var named  
'.toCharArray' is being searched for.

In the second case, I'm guessing that the classname provided as the  
first argument is being interpreted as a symbol and not a Class.  Just  
for comparison's sake:

user/ (eval '(java.lang.Enum/valueOf java.lang.Thread$State "NEW"))
#<State NEW>

(Also puzzling to me is the fact that the ClassCastException is being  
emitted by clojure's reflection apparatus; this is confusing to me, as  
Enum/valueOf has no overloads, and in any case, the types of the  
arguments is known -- Class and String, or in the case where the  
reader isn't swapping out the symbol for the Thread$State class, a  
Symbol and String.  That's for another day, though.)

I'm not entirely clear on all of the implications of #=, but it seems  
like a good deal of the reader functionality isn't available within #=  
forms.

Is this known and/or expected behaviour?

Thanks,

- Chas

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