RosettaCodeData/Task/Delegates/Clojure/delegates.clj

14 lines
297 B
Clojure
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
(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"))