Clojure

Add support for marker protocols

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Release 1.5
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test
  • Approval:
    Ok

Description

The attached patch adds support to marker protocols, for example

(defprotocol Sequential
"marker protocol indicating a sequential type")

Activity

Hide
Jonas Enlund added a comment -

Marker protocols are supported and used in ClojureScript.

Show
Jonas Enlund added a comment - Marker protocols are supported and used in ClojureScript.
Hide
Kevin Downey added a comment -

what are the uses for marker protocols? I know there are marker interfaces in java, but is it a pattern we want to carry forward?

Show
Kevin Downey added a comment - what are the uses for marker protocols? I know there are marker interfaces in java, but is it a pattern we want to carry forward?
Hide
Fogus added a comment -

Nice and simple. Tested with:

(defprotocol P (hi [_]))
(defprotocol M)
(deftype T [a] M P (hi [_] "hi there"))
(satisfies? P (T. 1))
(satisfies? M (T. 1))
(hi (T. 1))
(defprotocol M2 "marker for 2")
(extend-type T M2)
(satisfies? M2 (T. 1))

Similar tests are included in the additional patch file as test cases. This additional patch file should be applied after the feature's main patch file.

Show
Fogus added a comment - Nice and simple. Tested with:
(defprotocol P (hi [_]))
(defprotocol M)
(deftype T [a] M P (hi [_] "hi there"))
(satisfies? P (T. 1))
(satisfies? M (T. 1))
(hi (T. 1))
(defprotocol M2 "marker for 2")
(extend-type T M2)
(satisfies? M2 (T. 1))
Similar tests are included in the additional patch file as test cases. This additional patch file should be applied after the feature's main patch file.

People

Vote (2)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: