<< Back to previous view

[CLJ-966] Add support for marker protocols Created: 05/Apr/12  Updated: 18/Aug/12  Resolved: 18/Aug/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Release 1.5

Type: Enhancement Priority: Minor
Reporter: Nicola Mometto Assignee: Unassigned
Resolution: Completed Votes: 2
Labels: None

Attachments: File CLJ-966-additional-marker-tests-APPLY-AFTER.diff     File marker-protocols.diff    
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")



 Comments   
Comment by Jonas Enlund [ 07/Apr/12 1:20 PM ]

Marker protocols are supported and used in ClojureScript.

Comment by Kevin Downey [ 15/Aug/12 2:23 PM ]

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?

Comment by Fogus [ 15/Aug/12 2:40 PM ]

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.

Generated at Thu Apr 24 11:24:48 CDT 2014 using JIRA 4.4#649-r158309.