Re: questions on extending protocols

2010-03-22 Thread Stuart Halloway
Very helpful, thanks! Stu On Mar 22, 10:54 am, Stuart Halloway wrote: The questions below refer to the gist athttps://gist.github.com/ 336674/9ab832a86d203731c6379404d20afded79fe5f5b and to protocols in general: (1) Clojure automatically types hints the first argument when extending a pr

Re: questions on extending protocols

2010-03-22 Thread Rich Hickey
On Mar 22, 10:54 am, Stuart Halloway wrote: > >> The questions below refer to the gist > >> athttps://gist.github.com/336674/9ab832a86d203731c6379404d20afded79fe5f5b > >>  and to protocols in general: > > >> (1) Clojure automatically types hints the first argument when   > >> extending a protoc

Re: questions on extending protocols

2010-03-22 Thread Per Vognsen
Before someone dings me on the race condition, imagine I had factored those repeated @cache calls into a (let [value# @cache] ...) expression. The other thing I'm missing is a check for whether the protocol has been changed since the cache entry was created; this would be done by also maintaining a

Re: questions on extending protocols

2010-03-22 Thread Per Vognsen
>>> lookup (find-protocol-method) over the method invocation itself. Is that the >>> right way to summarize the performance implications? >> >> No, since the result is cached. The real every-call overhead is having to >> go through the var to detect changes to the protocol, vs the inline-defined >>

Re: questions on extending protocols

2010-03-22 Thread Konrad Hinsen
On 22 Mar 2010, at 14:12, Per Vognsen wrote: Even if the functions can be written in terms of the core protocol, putting them in the protocol makes it possible to implement higher-performance specialized versions for some containers while supplying default implementations in terms of the core pr

Re: questions on extending protocols

2010-03-22 Thread Stuart Halloway
The questions below refer to the gist at https://gist.github.com/336674/9ab832a86d203731c6379404d20afded79fe5f5b and to protocols in general: (1) Clojure automatically types hints the first argument when extending a protocol to an interface or class, which is great. But you cannot override

Re: questions on extending protocols

2010-03-22 Thread Per Vognsen
On Mon, Mar 22, 2010 at 7:20 PM, Rich Hickey wrote: > > On Mar 20, 2010, at 3:56 AM, Stuart Halloway wrote: > >> The questions below refer to the gist at >> https://gist.github.com/336674/9ab832a86d203731c6379404d20afded79fe5f5b and >> to protocols in general: >> >> (1) Clojure automatically types

Re: questions on extending protocols

2010-03-22 Thread Rich Hickey
On Mar 20, 2010, at 3:56 AM, Stuart Halloway wrote: The questions below refer to the gist at https://gist.github.com/336674/9ab832a86d203731c6379404d20afded79fe5f5b and to protocols in general: (1) Clojure automatically types hints the first argument when extending a protocol to an interfa

questions on extending protocols

2010-03-20 Thread Stuart Halloway
The questions below refer to the gist at https://gist.github.com/336674/9ab832a86d203731c6379404d20afded79fe5f5b and to protocols in general: (1) Clojure automatically types hints the first argument when extending a protocol to an interface or class, which is great. But you cannot override