Welcome! Please see the About page for a little more info on how this works.

+5 votes
in Protocols by
retagged by

Often, when you call clojure.core/extend directly (vs extend-type, extend-proto or inline definitions), that means you have some level of composition that happened upstream to create proto extensions for a type.

To recap today the signature of extend is as follows:

([atype & proto+mmaps])

Meaning when it's called it looks like

(extend t protoA {...} protoB {...})

I am advocating to just changing it to

([atype & {:as proto+mmaps}])

That would allow somebody calling into extend to pass either an "unrolled" map like today, or a regular map to it (leveraging the recent patch from @fogus).

(extend t {protoA {...} protoB {...}}) and (extend t protoA {...} protoB {...}) would be supported.

The alternative today when you have a proto+mmaps that is the result of merging implementations is to do something akin to:

(apply extend t (into [] cat proto+mmaps))

the patch would allow to do things such as:

(extend t (merge proto-impl-a proto-impl-b proto-impl-c ...))

I am happy to provide a patch for this if that's considered to be an acceptable change.

1 Answer

0 votes

Logged as https://clojure.atlassian.net/browse/CLJ-2756 (a more general problem description).