Hi all,
If you have a protocol
(defprotocol Foo (foo [x] [x y]))
and implement it for the record
(defrecord Bar [p q r]
Foo
(foo [x] x)
(foo [x y] [x y]))
you write each method separately. The same is true for extend-type. Yet, if
you use extend-protocol syntax is more like usual Clojure multi-arity
function definition:
(extend-protocol Foo
Bar
(foo
([x] x)
([x y] [x y])))
The first question is why there is a difference?
Secondly, if you mess up which syntax is where, the error you will get is
quite obscure, nothing guards you against essentially a *wrong syntax*:
both extend-type and extend-protocol are macros, so it shouldn’t be too
difficult to add a quick check on correctness.
But lastly, wouldn’t it be better to have a uniform syntax?
Regards,
Alexey
--
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/d/optout.