Re: Protocol as an abstract data type

2012-07-02 Thread Vinzent
IIndexed is the protocol that maps to nth. Well, IIndexed is the protocol behind -nth, and some dispatching also happens in nth itself. So there is two levels of dispatch: in the nth function (closed) and in the IIndexed protocol (open). See the Michał Marczyk's comment about IIndexable and

Re: Protocol as an abstract data type

2012-07-01 Thread Michał Marczyk
On 1 July 2012 16:39, David Nolen wrote: > On Sun, Jul 1, 2012 at 10:31 AM, Michał Marczyk > wrote: >> Additionally I would like to note that Haskell's ad hoc polymorphism >> solution, the system of type classes, allows for extensions predicated >> on a type class already being implemented: >> >>

Re: Protocol as an abstract data type

2012-07-01 Thread Michał Marczyk
On 1 July 2012 16:25, David Nolen wrote: > On Sun, Jul 1, 2012 at 9:04 AM, Vinzent wrote: >> Extend on nil, IIndexed and default (I realize that it's currently >> impossible in cljs). > > IIndexed is the protocol that maps to nth. We already extend IIndexed > to nil. Extending default to IIndexed

Re: Protocol as an abstract data type

2012-07-01 Thread David Nolen
On Sun, Jul 1, 2012 at 10:31 AM, Michał Marczyk wrote: > Additionally I would like to note that Haskell's ad hoc polymorphism > solution, the system of type classes, allows for extensions predicated > on a type class already being implemented: > > -- no dependencies on other type classes > instanc

Re: Protocol as an abstract data type

2012-07-01 Thread Michał Marczyk
Additionally I would like to note that Haskell's ad hoc polymorphism solution, the system of type classes, allows for extensions predicated on a type class already being implemented: -- no dependencies on other type classes instance SomeClass SomeType where ... -- depend on OtherClass being imp

Re: Protocol as an abstract data type

2012-07-01 Thread David Nolen
On Sun, Jul 1, 2012 at 9:04 AM, Vinzent wrote: > Extend on nil, IIndexed and default (I realize that it's currently > impossible in cljs). IIndexed is the protocol that maps to nth. We already extend IIndexed to nil. Extending default to IIndexed leads to horrible things like the following: (ind

Re: Protocol as an abstract data type

2012-07-01 Thread Michał Marczyk
On 1 July 2012 15:04, Vinzent wrote: > Extend on nil, IIndexed and default (I realize that > it's currently impossible in cljs). Actually it is possible and it is how things were originally implemented. The move to the current implementation happened as part of an effort to make things faster. Th

Re: Protocol as an abstract data type

2012-07-01 Thread Vinzent
Extend on nil, IIndexed and default (I realize that it's currently impossible in cljs). воскресенье, 1 июля 2012 г., 18:39:27 UTC+6 пользователь David Nolen написал: > > How do you think the conditionals can be removed? > > On Sunday, July 1, 2012, Vinzent wrote: > >> Just an idea: predicate dis

Re: Protocol as an abstract data type

2012-07-01 Thread David Nolen
How do you think the conditionals can be removed? On Sunday, July 1, 2012, Vinzent wrote: > Just an idea: predicate dispatch can be combined with protocols into one > thing, eliminating the need for defrecord-like things at all. Low level > types defined with deftype, higher-level abstractions de

Re: Protocol as an abstract data type

2012-07-01 Thread Vinzent
Just an idea: predicate dispatch can be combined with protocols into one thing, eliminating the need for defrecord-like things at all. Low level types defined with deftype, higher-level abstractions defined with that "dynamic protocols" thing. It'd be fun to play with it :) Don't you think the

Re: Protocol as an abstract data type

2012-06-30 Thread David Nolen
On Sat, Jun 30, 2012 at 11:15 PM, Mark Engelberg wrote: > > In any case, I feel like I understand better how you've structured things in > ClojureScript and what can and can't be done easily with protocols. Thanks! I think predicate dispatch + protocols could eliminate the existing closed cases.

Re: Protocol as an abstract data type

2012-06-30 Thread Warren Lynn
implementation which only supports one abstract protocol!) I don't feel strongly about last specifically, but if people wanted it to behave polymorphically, I'd be happy to volunteer to write the code. Thanks a lot for the detailed analysis and volunteering to write the code. Not surprisingly

Re: Protocol as an abstract data type

2012-06-30 Thread Mark Engelberg
OK, I get it now. Protocols are attached to very specific capabilities. With this structure, it is easy to: Write a function that operates on an input that fulfills a specific protocol. Write a function that operates on an input that fulfills (all of) multiple protocols. Write a function that op

Re: Protocol as an abstract data type

2012-06-30 Thread Mark Engelberg
Never mind, found it. -- 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 grou

Re: Protocol as an abstract data type

2012-06-30 Thread Mark Engelberg
On Sat, Jun 30, 2012 at 9:36 PM, David Nolen wrote: > Look at the implementation of nth. Or how polymorphic unification works in > ClojureScript core.logic for ISequential. I misspoke a bit, should have > clearer that I simply meant that ILast (probably something else entirely) > needs to be care

Re: Protocol as an abstract data type

2012-06-30 Thread David Nolen
Look at the implementation of nth. Or how polymorphic unification works in ClojureScript core.logic for ISequential. I misspoke a bit, should have clearer that I simply meant that ILast (probably something else entirely) needs to be carefully considered since the logic needs too be moved to the act

Protocol as an abstract data type

2012-06-30 Thread Mark Engelberg
This is a continuation of issues raised in the thread about making the core "last" function behave in a polymorphic manner. The separation of interfaces from implementation in Java serves several purposes, but one thing it does is it allows the creation of abstract data types, i.e., a type that is