Hi,
you can still use a defrecord. Just don't implement the protocol inline.
Clojure
user=> (ns foo.bar (:refer-clojure :exclude [get]))
nil
foo.bar=> (defprotocol FooBar (get [this]))
FooBar
foo.bar=> (ns foo.baz)
nil
foo.baz=> (alias 'fb 'foo.bar) ; this is due to working only in the repl.
Normally you would use :require in the ns clause.
nil
foo.baz=> (defrecord Baz [a b c])
foo.baz.Baz
foo.baz=> (extend-type Baz
fb/FooBar
(get [{:keys [a b c]}] (str a b c)))
nil
foo.baz=> (fb/get (->Baz "fo" "ob" "ar"))
"foobar"
Implementing a protocol inline is an optimisation, not a requirement.
Meikel
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.