A custum constructor (aka factory function) is even considered idiomatic https://github.com/swannodette/lt-cljs-tutorial/blob/master/lt-cljs-tutorial.cljs#L1289 <https://github.com/swannodette/lt-cljs-tutorial/blob/master/lt-cljs-tutorial.cljs#L1289>
HIH mimmo > On 27 Dec 2015, at 17:22, [email protected] wrote: > > I'm wondering about the record usage where a record would have relations > between its fields. This would be best explained with the following example: > > user=> (defrecord Time [minutes seconds]) > > user.Time > > user=> (->Time 0 59) > > #user.Time{:minutes 0, :seconds 59} > > user=> (update (->Time 0 59) :seconds inc) > > #user.Time{:minutes 0, :seconds 60} > > > It's not very nice since 60 seconds is not really a valid value. If it would > be possible to define so that > > > > > user=> (Time. 0 60) > #user.Time{:minutes 1, :seconds 0} > > > > then if I'm reading emit-defrecord correctly, assoc and therefore update etc. > would work as expected here. Would this be semantically against principles of > record or could some kind of structure to modify the fields while creating a > new instance of a record be considered as part of Clojure? > > > > > > Juho > > > > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to [email protected] > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > <http://groups.google.com/group/clojure?hl=en> > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
