Re: Datatypes and Protocols - early experience program

1 view
Skip to first unread message

Konrad Hinsen

unread,
Nov 12, 2009, 10:57:17 AM11/12/09
to cloju...@googlegroups.com
On 12.11.2009, at 13:10, Rich Hickey wrote:

> If you have the time and inclination, please try them out. Feedback is
> particularly welcome as they are being refined.

I converted a simple interface defined in terms of multimethods to the
new protocol/extend mechanism. Overall I am happy with the change,
since the code is more compact and better structured. However, I have
a couple of test case failures that make me suspect that the protocol
extension being used is not always the one I expect.

More specifically, I have
- a protocol definition
- a default extension for Object
- three extensions for three different Java classes

Two of the three extensions work as expected, but for objects of the
third Java class it looks as if the default implementation for Object
is called instead. Could this be a bug in the current protocol
implementation? The same arrangement with multimethods works fine.

I can provide all the code (in fact, I am planning to put it on Google
Code anyway), but it depends on two Java libraries. I didn't yet find
a way to reproduce this problem with classes from the Java standard
library.

Konrad.

Rich Hickey

unread,
Nov 12, 2009, 1:14:50 PM11/12/09
to cloju...@googlegroups.com
Yes, as indicated here:

https://www.assembla.com/wiki/show/clojure/Protocols

it is "TBD - how to specify which impl to use", and right now there is
no defined selection policy. There will be of course, and it will be
straightforward for class derivation (follow the super chain).

I have mixed feelings about continuing to support multiple inheritance
of implementations via interfaces.

I'll get the follow-the-super-chain logic in soon so your testing can
move forward.

Rich

Rich Hickey

unread,
Nov 12, 2009, 2:03:32 PM11/12/09
to cloju...@googlegroups.com
Ok, that's up.

Uses hierarchy to determine impl given multiple extends in
superclasses of target, now:

target type
target class
superclasses (not interfaces) of target (in reverse derivation order,
not including Object) interfaces (in arbitrary order for now)
Object

Rich

Konrad Hinsen

unread,
Nov 13, 2009, 3:31:11 AM11/13/09
to cloju...@googlegroups.com
On 12 Nov 2009, at 20:03, Rich Hickey wrote:

>> I'll get the follow-the-super-chain logic in soon so your testing can
>> move forward.
>
> Ok, that's up.
>
> Uses hierarchy to determine impl given multiple extends in
> superclasses of target, now:
>
> target type
> target class
> superclasses (not interfaces) of target (in reverse derivation order,
> not including Object) interfaces (in arbitrary order for now)
> Object

Thanks, that works fine!

Konrad.

Reply all
Reply to author
Forward
0 new messages