On Sun, Feb 14, 2010 at 8:56 AM, Stuart Sierra
<the.stuart.sie...@gmail.com> wrote:
> Rich's stated reason against this is that he wants to be able, some
> day, to implement maps and map-like things with deftype.

Hmmm, if so, then there's a bit of a design tension between that goal
and the goal of "prefer deftype to defstruct in all cases", which
implies that deftype is going to play an important everyday role in
the Clojure programmer's toolkit (not just a behind-the-scenes thing)
and therefore, it's very important to optimize for the "common case".
I find it hard to believe that implementing maps and map-like things
will be the common case.

It sounds to me like there are a few options here, depending on what
you view the common case to be:
1.  Do nothing and leave things as-is.  This forces the user to choose
between no easy update ability, and full-blown map behavior where you
can add/remove keys however you like.
2.  Create a way to opt-in to just the "assoc of deftype's built-in keys".
3.  By default, allow "assoc of deftype's built-in keys", but provide
a way to opt out of this.

I think #1 is the worst option.  I definitely prefer #3 over #2
because I believe it is the most common case, but I can imagine a case
could be made for #2 over #3.  However, if it's going to be an
"opt-in" system for something as fundamental as assoc on built-in
keys, I think it would be great if there were a syntactically
beginner-friendly way to accomplish this.  For a beginner coming to
Clojure, I think it will feel too much like a "magic incantation" to
have to explicitly mix-in some kind of implementation of
IPersistentMap that throws errors for all but the "assoc of built-in
keys" case, since beginners are unlikely to need or want to know how
Clojure's interfaces are layered and implemented behind-the-scenes in
order to get a "(persistent) structure with settable fields".

-- 
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