If you (set! *warn-on-reflection* true) you'll see that the first uses
reflection while the second doesn't.  This is (imo) a bug in the
method resolution behavior, namely that the code path for looking up
compiled calls is different from reflected calls.

I submitted a patch to fix both this divergence and to allow for more
correct lookup behavior when it comes to primitive args:
https://www.assembla.com/spaces/clojure/tickets/445

Note that with the patch applied both scenarios result in a "More than
one matching method found" exception, which is (imo) the correct
behavior.

Feel free to bug Stu, et al., to get the patch applied.  ;)


On Oct 26, 7:44 am, Maks Romih <mak...@gmail.com> wrote:
> Hi!
>
> I stumbled on a difference of behavior in using a variable vs. let
> binding. It may even be a bug in Clojure.
>
> Using Java 1.6 and Clojure 1.1 or 1.2, if you execute the following
> code
>
> <code>
> (import
>  'javax.xml.crypto.dsig.XMLSignatureFactory
>  'javax.xml.crypto.dsig.Transform)
>
> (def fac (XMLSignatureFactory/getInstance "DOM"))
>
> (let [tf (. fac newTransform Transform/ENVELOPED nil)]
>   tf)
>
> (let [fac (XMLSignatureFactory/getInstance "DOM")
>       tf (. fac newTransform Transform/ENVELOPED nil)]
>   tf)
> </code>
>
> the first let works OK while the second one breaks with stack trace
> and the error "More than one matching method found: newTransform".
> There are really two methods with this name and the second parameter
> nil does not differentiate them enough, but I'd like to know why the
> first call, with the fac as a variable, succeeds. Which method of the
> two does it call?
>
> Maks.

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