On Mar 15, 10:50 am, Mark Engelberg <mark.engelb...@gmail.com> wrote:
> On Tue, Mar 15, 2011 at 10:40 AM, Alan <a...@malloys.org> wrote:
> > Seconded. I often know ahead of time I'll want to extend to
> > multimethods eventually, but sometimes I don't. Because multimethods,
> > protocols, and plain-old-functions look the same to the caller, you
> > can write your code whatever way is most straightforward first, and
> > add in higher-octane stuff when you discover you need it. Nobody need
> > ever know.
>
> Yes, but beware, record constructors are not plain old functions and do not
> look the same as other sorts of constructors, so that can be an issue if you
> think you might change representation midway.

This only causes issues if you (a) switch "down" from protocols to
something else, and (b) didn't do records right in the first place
(usually I do them wrong!).

Going from
(defn make-line [p1 p2] {:p1 p1 :p2 p2})
to
(defrecord Line [p1 p2] Shape (draw [this] ...))
(defn make-line [p1 p2] (Line. p1 p2))

does not give anyone backwards-compatibility issues. You just make
sure there's still a clojure-level first-class function responsible
for delegating to the record constructor.

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