On 27 Apr 2010, at 09:20, Mark Engelberg wrote:

I understand that you can always do "Foo." to construct a Foo record,
but these constructors don't act as full-fledged functions, right?

No. They are not first-class objects (in fact, not objects at all in the JVM sense), so you can't pass them around.

Honestly, for me the main issue is just that subjectively, it is less
satisfying to create a Clojure data structure and end up with
something that you construct with Java interop syntax.  I'd like
Clojure data structures to look and feel "Clojurish" not "Javaish"

That was my initial reaction as well. However, I just write my own factory functions now, and this gives me the opportunity to add argument validation in any way I like.

BTW, another change is that the defined type is a Java class, whereas before it was a var pointing to the factory function. Not being a var means that the type doesn't really reside in the namespace. In particular, a :use of the namespace doesn't get you the type, you have to :import it.

Taken together, these changes make deftype and defrecord low-level features for defining data types that are best exposed to the outside world via a functional API. Your clients don't need to know that there's a Java type with a constructor hidden somewhere.

Konrad.

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