Re: type hinting overloaded methods

2013-12-12 Thread Phillip Lord
Phillip Lord writes: > Mikera writes: > >> On Wednesday, 11 December 2013 14:50:36 UTC, Phillip Lord wrote: >> Macros that generate type hints can get pretty ugly. > > Yes, I notice that! > >> I ran into the same problem with vectorz-clj >> >> The following pattern ended up working for me: the

Re: type hinting overloaded methods

2013-12-11 Thread Phillip Lord
Mikera writes: > On Wednesday, 11 December 2013 14:50:36 UTC, Phillip Lord wrote: > Macros that generate type hints can get pretty ugly. Yes, I notice that! > I ran into the same problem with vectorz-clj > > The following pattern ended up working for me: the trick to to create a > local symbo

Re: type hinting overloaded methods

2013-12-11 Thread Mikera
On Wednesday, 11 December 2013 14:50:36 UTC, Phillip Lord wrote: > > Mikera > writes: > > > On Wednesday, 11 December 2013 13:37:24 UTC, Philipp Meier wrote: > >> Implementing a clojure protocol will give you fast dispatch on the > first > >> argument's type. > >> > > > > Very true... it's a

Re: type hinting overloaded methods

2013-12-11 Thread Phillip Lord
Mikera writes: > On Wednesday, 11 December 2013 13:37:24 UTC, Philipp Meier wrote: >> Implementing a clojure protocol will give you fast dispatch on the first >> argument's type. >> > > Very true... it's a tradeoff: > - protocols allow open extension (which doesn't appear to be needed here?) >

Re: type hinting overloaded methods

2013-12-11 Thread Mikera
On Wednesday, 11 December 2013 13:37:24 UTC, Philipp Meier wrote: > > Hi, > > Am Mittwoch, 11. Dezember 2013 14:27:01 UTC+1 schrieb Mikera: >> >> You can't really avoid the instance checks: the underlying mechanic is >> that the JVM needs to figure out somehow at runtime which overloaded method >

Re: type hinting overloaded methods

2013-12-11 Thread Philipp Meier
Hi, Am Mittwoch, 11. Dezember 2013 14:27:01 UTC+1 schrieb Mikera: > > You can't really avoid the instance checks: the underlying mechanic is > that the JVM needs to figure out somehow at runtime which overloaded method > version to call, since all it knows at compile time is that it has an > ar

Re: type hinting overloaded methods

2013-12-11 Thread Mikera
You can't really avoid the instance checks: the underlying mechanic is that the JVM needs to figure out somehow at runtime which overloaded method version to call, since all it knows at compile time is that it has an arbitrary Object. instance? is the simplest way to do this. There are some fa

Re: type hinting overloaded methods

2013-12-10 Thread John D. Hume
On Tue, Dec 10, 2013 at 4:25 AM, Phillip Lord wrote: > (defn ^IRI iri > [name] > (cond >(instance? String name) >(IRI/create ^String name) >(instance? java.net.URL name) >(IRI/create ^java.net.URL name) >(instance? java.io.File name) >(IRI/create ^java.io.File name))) >