Re: Style - Keyword access or accessors?

2014-04-25 Thread Mimmo Cosenza
I do as Dan does. Sometimes I prefer to use defrecord instead of a regular map, e.g. when there are mutable values involved. In such a case I always define a constructor for the record instances. mimmo On 22 Apr 2014, at 12:06, Colin Yates colin.ya...@gmail.com wrote: Thanks Dan, One

Re: Style - Keyword access or accessors?

2014-04-24 Thread Jason Wolfe
FWIW, internally we use a combination of schema and religious use of letk or safe-get and safe-get-in (from prismatic/plumbing) to pull things out of object-like maps, which together with reasonable test coverage seem to catch almost all of the keyword typos before they become bugs. The other

Re: Style - Keyword access or accessors?

2014-04-24 Thread Mars0i
I do think there's a legitimate role for routine use of accessors in some contexts, btw. I seem to have been traumatized by my experience with them, however. :-) On Thursday, April 24, 2014 12:48:04 AM UTC-5, Mars0i wrote: One of the things I hated about Java when I did Java programming for

Re: Style - Keyword access or accessors?

2014-04-23 Thread Mars0i
One of the things I hated about Java when I did Java programming for a living, a number of years ago, was having to define accessors, over, and over, and over again for each class. What a waste of time! (Not to mention the instance in which we made a client move to using paper rather than

Style - Keyword access or accessors?

2014-04-22 Thread Colin Yates
(This has been discussed before but as this is fairly subjective I am interested in whether people's opinion has changed) What are people's experiences around using keywords or defined accessors for navigating data structures in Clojure (assuming the use of maps)? Do people prefer using raw

Re: Style - Keyword access or accessors?

2014-04-22 Thread Daniel Kersten
I've personally always used keywords. I don't see any value in aliasing :foo to foo. For navigating nested maps, get-in, update-in and assoc-in with keywords seem natural and practical to me. On 22 April 2014 10:43, Colin Yates colin.ya...@gmail.com wrote: (This has been discussed before but

Re: Style - Keyword access or accessors?

2014-04-22 Thread Colin Yates
Thanks Dan, One benefit is compile time safety and the refactoring I mentioned. But yes, I am coming around to the notion of just using raw keywords... On Tuesday, April 22, 2014 10:49:33 AM UTC+1, Dan Kersten wrote: I've personally always used keywords. I don't see any value in aliasing

Re: Style - Keyword access or accessors?

2014-04-22 Thread Jim
there is really no reason to use `get-in` with keywords/symbols as they know how to look themselves up...in other words, you don't need to pay for any polymorphic calls : (get-in [:a :b :c :d] someMap) = (- someMap :a :b :c :d) Jim On 22/04/14 10:49, Daniel Kersten wrote: For navigating

Re: Style - Keyword access or accessors?

2014-04-22 Thread Colin Yates
Nice. On Tuesday, April 22, 2014 11:36:06 AM UTC+1, Jim foo.bar wrote: there is really no reason to use `get-in` with keywords/symbols as they know how to look themselves up...in other words, you don't need to pay for any polymorphic calls : (get-in [:a :b :c :d] someMap) = (- someMap :a

Re: Style - Keyword access or accessors?

2014-04-22 Thread Alex Miller
Clojure is designed to make your data accessible generically without getters/setters or other custom APIs so I would encourage direct access via keywords over accessor fns. One consequence of this is that fns using a data structure have a direct coupling to the structure of the data. I prefer

Re: Style - Keyword access or accessors?

2014-04-22 Thread Colin Yates
Thanks Alex. Yep, I think Prismatic's schema is going to be invaluable for making the data structure less opaque and providing the comfort that I have lost from the lack of a rigorous and extensive strict type system (carefully avoiding the use of strong, lose, static and dynamic :)). On