Re: Protocols and Types

2010-03-03 Thread Konrad Hinsen
On 03.03.2010, at 16:05, Andrea Tortorella wrote: > given that a protocol is represented as a simple map, which is the > way to know if something is infact a protocol. I don't think that is possible without relying on undocumented characteristics that are likely to change. What do you need this

Re: Protocols and Types

2010-03-03 Thread Andrea Tortorella
I'm not on my machine so i'cant experiment, i tried on #clojure with clojurebot but it's not 1.2, so i ask here, given that a protocol is represented as a simple map, which is the way to know if something is infact a protocol. Or suppose i want to add a function that works on protocols how can i

Re: Protocols and Types

2010-03-03 Thread Meikel Brandmeyer
Hi, On Mar 3, 2:43 pm, Andrea Tortorella wrote: You have to use some instance of T. > (extends? P T) > ;==> nil (extends? P some-t) will return false, because you don't call extend explicitly. > (satisfies? P T) > ;==> nil (satisfies? P some-t) will return true. > (extenders P) > ;==>nil S

Re: Protocols and Types

2010-03-03 Thread Stuart Halloway
Hi Andrea, You need to make two little changes: (1) satisfies? is a predicate about instances, not types, and (2) the extend predicates check for explicit extension: (defprotocol P (foo [x])) (deftype T []) (extend ::T P {:foo (fn [] "dummy")}) (extends? P T) => true (satisfies? P (

Re: Protocols and Types

2010-03-03 Thread Konrad Hinsen
On 03.03.2010, at 14:43, Andrea Tortorella wrote: > (extends? P T) > ;==> nil > (satisfies? P T) > ;==> nil > (extenders P) > ;==>nil The doc string of both extends? and extenders refers to types "explicitly extending" a protocol. My understanding is that this excludes protocols implemented via

Re: Protocols and Types

2010-03-03 Thread Shawn Hoover
On Wed, Mar 3, 2010 at 8:43 AM, Andrea Tortorella wrote: > Hi everyone, > > if I run this code: > > (defprotocol P > (foo [x])) > > (deftype T [] > P > (foo [] "dummy")) > > (extends? P T) > ;==> nil > (satisfies? P T) > ;==> nil > (extenders P) > ;==>nil > > are they not yet implemented? > Ni