> > I am not sure I follow...If you're just creating a new record yourself, > you can pass whatever you want to the constructor...no need for > 'setting' whatsoever...On the other hand if you're consuming an object > then you might need to 'set' some fields before it is useful (where doto > comes into play). > > > I have a feeling we may not be talking about the same thing here. What I want is constructors, not a "setter". My understanding is, in Clojure there is no constructors for record other than simply passing in the field values (directly or in a map). And hence I am proposing to have some constructors similar to other OO languages. Having constructors have nothing to do with immutability.
Here is a maybe silly example, but hope it communicates what I want. I want something like this: (defrecord Book [age-min age-max] (make-record "Make a book for an age group" [age-min age-max] (when (> age-min age-max) (throw (IllegalArgumentException. "Minimum age is greater than maximum age."))) (Book. age-min age-max))) (make-record Book 6 5) => IllegalArgumentException (make-record Book 3 5) => Book#{:age-min 3 :age-max 5} BTW, this not to argue with you. But I sometimes I feel some people have some kind of extreme opposition against anything associated with OO. I just think people designing and using OO languages are no all that stupid. -- 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