Re: defrecord/deftype ...

2011-02-18 Thread Laurent PETIT
For one, the type of a record is not as malleable as the other attributes of the record. It's less dynamic. 2011/2/18 Base > Thank you Stuart! This makes perfect sense and is quite elegant. > > So is performance the only compelling reason to do this? I am assuming > there are times that maps ar

Re: defrecord/deftype ...

2011-02-18 Thread Ken Wesson
On Fri, Feb 18, 2011 at 5:31 PM, Base wrote: > Are there some things that you can do with maps that you cannot do > with defrecord? Round-trip them through prn/read without them turning into something else. -- You received this message because you are subscribed to the Google Groups "Clojure" g

Re: defrecord/deftype ...

2011-02-18 Thread Base
Thank you Stuart! This makes perfect sense and is quite elegant. So is performance the only compelling reason to do this? I am assuming there are times that maps are 'good enough', but would you say that if you ever have a defined data structure you would advise to use defrecord to gain this incr

Re: defrecord/deftype ...

2011-02-18 Thread Stuart Sierra
Hi Base, It's easy, because instances of defrecord behave identically to maps. Say you have a lot of "person" records that look like this: {:first-name "Stuart", :last-name "Sierra", :location "NYC"} You might write a constructor function to create these maps: (defn person [& options]

Re: defrecord/deftype ...

2011-02-18 Thread Base
Hi Stuart - I am very much still learning Clojure and havent waded into defrecord, etc. Could you provide an example of how you wold start with a map and shift to a defrecord in the future? Thanks Base On Feb 18, 11:16 am, Stuart Sierra wrote: > One purpose of defrecord was to be interchangea

Re: defrecord/deftype ...

2011-02-18 Thread Stuart Sierra
One purpose of defrecord was to be interchangeable with maps, so that you can prototype with maps, then switch to defrecord for better performance without changing much code. If you use constructor functions to create instances of your records/maps, you hardly have to change anything at all. A

Re: defrecord/deftype ...

2011-02-16 Thread Michael Ossareh
> > Do you have more details of this - it sounds interesting... > A very rough answer: https://github.com/ossareh/clj-boilerplate I've some local changes that will go up in a few days that make this "better" - they're based off me actually using the framework where as what is there right now is m

Re: defrecord/deftype ...

2011-02-16 Thread Saul Hazledine
On Feb 16, 6:07 pm, Michael Ossareh wrote: > One place it has mattered is in using compojure with ring. I'm building a > few middlewares that permit my applications to have a good sense of > structure (somewhat MVC ish) in that process I discovered that to be > compojure compatible you must return

Re: defrecord/deftype ...

2011-02-16 Thread David Nolen
On Wed, Feb 16, 2011 at 1:23 AM, Sunil S Nandihalli < sunil.nandiha...@gmail.com> wrote: > Just thinking out loud... > After listening to "classes are a premature optimization" lecture on infoQ > .. I was just wondering if the only purpose of defrecord is space&speed > efficiency ... and could jus

Re: defrecord/deftype ...

2011-02-16 Thread Michael Ossareh
One place it has mattered is in using compojure with ring. I'm building a few middlewares that permit my applications to have a good sense of structure (somewhat MVC ish) in that process I discovered that to be compojure compatible you must return a supported type or extend the Renderable protocol.

Re: defrecord/deftype ...

2011-02-16 Thread Laurent PETIT
2011/2/16 Sunil S Nandihalli > Just thinking out loud... > After listening to "classes are a premature optimization" lecture on infoQ > .. I was just wondering if the only purpose of defrecord is space&speed > efficiency ... and could just use maps .. ofcourse .. I won't be able to use > the prot

Re: defrecord/deftype ...

2011-02-16 Thread Sunil S Nandihalli
Thanks Michael. yea true .. but I don't think I will miss them much .. :) Sunil. On Wed, Feb 16, 2011 at 12:32 PM, Michael Ossareh wrote: > Am I missing something? >> > > types. > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to thi

Re: defrecord/deftype ...

2011-02-15 Thread Michael Ossareh
> > Am I missing something? > types. -- 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 unsubscrib