RosettaCodeData/Task/Delegates/Clojure/delegates.clj
2018-06-22 20:57:24 +00:00

13 lines
297 B
Clojure

(defprotocol Thing
(thing [_]))
(defprotocol Operation
(operation [_]))
(defrecord Delegator [delegate]
Operation
(operation [_] (try (thing delegate) (catch IllegalArgumentException e "default implementation"))))
(defrecord Delegate []
Thing
(thing [_] "delegate implementation"))