Tangentially: In this particular case, reflection isn't strictly necessary
because toString is a method of Object. In theory, the compiler could
special-case Object's methods and never do reflection, right?
In practice, I don't know if it's worth the effort, although it's certainly
a little
Thanks for the clarification.
Just to clear up any confusion, the .toString example was just the
simplest example I could think of that illustrated was I was seeing
with regards to reflection and type hints :)
On Oct 20, 4:22 am, Michael Fogus mefo...@gmail.com wrote:
Another potential option
You can't really fix that, because (:foo bar) means call
function :foo on bar, and in general the function :foo returns
Object. (.foo bar) says look at the Java object bar, and give me its
foo member. Because there is a typehint on that, Clojure can know
what return type to expect.
On Oct 19,
I am using a record to wrap a number of java classes, which I then
access various properties on. I am trying to avoid reflection so I
type have type hinted, however when accessing the values in the record
the type hints are lost. It might look something like this
(defrecord Rec [^Integer i])
I am using a record to wrap a number of java classes, which I then
access various properties on. I am trying to avoid reflection so I
type have type hinted, however when accessing the values in the record
the type hints are lost. It might look something like this
(defrecord Rec [^Integer