How About Default Implementations on Protocols

Description

Consider this example

What about the default implementation.

Environment

None

Activity

Show:

importOctober 12, 2014 at 6:36 PM

Comment made by: mobiusinversion

I agree, this is a low priority enhancement. I think it could make the Protocol experience more DWIMy, and Java 8 has default implementations on interfaces for the same kind of convenience.

Jozef WagnerOctober 12, 2014 at 7:01 AM

I don't think we need it. What's the rationale behind extending some protocol, not implementing its methods, and then calling those methods, expecting them not to throw. Be explicit about what yout type should do, whether it is a default or custom behavior. You basically have three options

or

or

I think however that my first approach is unidiomatic and you should prefer the latter ones.

importOctober 12, 2014 at 2:48 AM

Comment made by: mobiusinversion

As it stands you have to workaround with this

http://stackoverflow.com/questions/15039431/clojure-mix-protocol-default-implementation-with-custom-implementation

Details

Assignee

Reporter

Priority

Created October 12, 2014 at 2:46 AM
Updated May 15, 2017 at 10:26 PM