Hi guys : In java we've all had the experience of using our ide to "traverse" down the depths of a complex data type :
dog.getCollar().getCollarTag().getName();
However, in Clojure, this becomes non trivial, due to the lack of static typing. How do we "defend" or Clojure against complexites that might arrive from nested data structures?
1) An advisable "limit" to the depth of clojure data structures ?
and
2) A common idiom for dealing with abritrarily deeply nested data structures, which prevents errors such as mistaking a list for map, or failing to correctly lower/upper case a variable name ?
Forgive me if I'm sounding a little off paradigm here ... It might be the case that such errors are efficiently curbed by continually testing in the REPL .. However, I was wondering if there are any other methods for making sure, at compile time, that code is as correct as possible (i.e. unit tests, IDE / emacs plugins, etc...)
keywords are your friend here
try to stick with maps because they are more inherently self describing.
Then play with the thread first and
..macroesand take advantage of the fact that keywords are also functions that look them selves up in a map.
When you work in an IDE with code completion it is parsing the code and then building data about that code, then parsing that data to produce it's suggestions. If your data is in it's self declarative (it can be 'read') then you get this even without the IDE.
ps: this leads to the standard rant about "code is data" has been expressed many times over by people much smarter than I :)