Hello, On Mon, Nov 2, 2009 at 8:03 PM, dmiller <dmiller2...@gmail.com> wrote: > > > One thing to keep in mind in any proposed solution: CLR allows > overloading a ref/out param against a non-ref/out param. > > class Test > { > static void m(int x) { ... } > static void m(ref int x) { ... } > } > > So not just result handling is needed, but also interop calls > themselves sometimes need a hint: > > (Test/m a) // which method is being called?
Is this never a problem in Java? I was quite surprised to see it's not :-) For instance, in Clojure JVM: user=> (def a (StringBuilder.)) #'user/a user=> (.append a 1.0) #<StringBuilder 1.0> user=> (.append a [1 2 3]) #<StringBuilder 1.0[1 2 3]> user=> (.append a 0x1b) #<StringBuilder 1.0[1 2 3]27> seems to be able to discern between StringBuilder.append(int) and StringBuilder.append(float). How is this done? (Storing things in vars also doesn't seem to be a problem - hmm, everything ends up in StringBuilder.append(object) ?!?). Anyway, I thought Clojure JVM needs help in these situations too and that the correct method is selected using type hints. Which is my proposed solution for C# too (with a modified type hint): (Test/m #^ref/Int32 a) should call Test.m(ref int x) and (Test/m #^Int32 a) should call Test.m(int x), while (Test/m a) should throw an exception because it can't pick a method. So ... a mandatory uglified type hint. Language design is hard :-) there are probably much better alternatives. Cheers, -- Miron Brezuleanu --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---