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
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
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
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
(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
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
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
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
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
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
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
11 matches
Mail list logo