On Mon, May 21, 2012 at 10:12 AM, nicolas.o...@gmail.com <
nicolas.o...@gmail.com> wrote:

> The point is not whether deftype is useful or not. It is in the
> language so it must be useful, even it it is rarely.
> The point is whether it is an expressive construct or not.
> And it is not expressive enough to my taste.
>
>
I'd go further and say that an important benchmark for any new language
construct designed to support modularity, composability, and reuse is the
degree to which it can support reuse in contexts unforeseen by the original
author of the code.

The whole beauty of protocols, for example, is that unlike interfaces, you
can graft it on to a type that wasn't originally designed to support it.
This is good, and a step forward from other languages.

On the other hand, defrecord/deftype encourage you to write your protocol
implementation in a way that cannot be reused unless you very specifically
plan for it (factoring the protocol implementation into a separate map) and
use a coding style that (might?) be less efficient (i.e., adding the
protocol implementation via extend rather than directly in defrecord).
This is not so good and potentially limits the value of protocols for
developing complex systems.  There are a lot of bad things about
inheritance, but the one good thing about it is that it provides a certain
way to extend and modify the behavior of objects in ways that were not
foreseen or planned for.  It would be nice if we could find a tasteful way
to get that back with protocols without opening the entire inheritance can
of worms.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to