On Sun, Dec 26, 2010 at 7:18 PM, Alex Osborne <a...@meshy.org> wrote:
> Damon Snyder <drsny...@gmail.com> writes:
>
>> One of the decisions I wasn't sure about was whether to use a protocol
>> or a struct map for the (socket, reader, writer) tuple. I started
>> using a struct-map and then switched over to defprotocol/defrecord.
>> See 
>> https://github.com/drsnyder/beanstalk/blob/82f301f1f825bb05aa14d85a220ec57c1dea61b2/src/beanstalk/core.clj#L117
>> for the definition.
>
> Struct maps were in the language for a long time before defrecord was
> added.  Records are supposed to replace them for most purposes.  So if
> in doubt between the two use a defrecord.

Isn't one advantage of structmaps over records that you don't need to
AOT your structmaps? And can thus change them on the fly during
REPL-driven programming, debugging, and experimentation instead of
having to do a discrete edit, build, test cycle?

I'd suggest at least using structmaps until you've debugged the
algorithms and finalized the design of the structmap itself (its
fields and their semantics) and then perhaps convert them to records
and, perhaps, add nice behaviors like seqability or whatever layered
onto the already-tested functionality. Jumping straight to defrecord
might, in some cases, be premature optimization, too.

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