diff --git a/src/clj/com/rpl/specter/impl.clj b/src/clj/com/rpl/specter/impl.clj index 095cd1c..c64acb0 100644 --- a/src/clj/com/rpl/specter/impl.clj +++ b/src/clj/com/rpl/specter/impl.clj @@ -47,6 +47,16 @@ (defprotocol CoerceTransformFunctions (coerce-path [this])) +;; In addition to the warning below, maybe just add a macro that makes it easy +;; for people to define records the way you recommend? It might be easier to +;; say "use my defrecord instead" than to explain what the advantage is. +(defmacro defrecord* + [name- elts protocol & impls] + ~(do (defrecord ~name- ~elts) + (extend-protocol + ~protocol ~name- + ~@impls))) + (defn no-prot-error-str [obj] (str "Protocol implementation cannot be found for object. Extending Specter protocols should not be done inline in a deftype definition