I'm used to Java code, with its long descriptive names, and with lots of temporary variables used only to give a name to some return value. This kind of code is very easy to understand even after a year break.
When using Lisp, however, I can't understand things like "what is in the 3rd position of this list" the next day, or even next hour.
This problem is fatal, because I have lots of records of several fields, and in Java you call myRecord.mass
and it's clear that it's mass, while (nth my-record 2)
doesn't make sense at all.
Is there any practice that makes possible to write self-documenting Lisp (namely, Clojure) code in such way that there can't be questions like "what kind of data is in this position of a list"?
Or
Is it OK to pass around lots of small (~5 items) clojure Map
structures?
Conclusion
The very feature I want is StructMaps -- array-based maps with shared set of keys.
Concerning self-documentation. As was with me in the case of R it was the standard library that confused me. Most builtin functions have rather non-descriptive names, and that has two consequences:
- You have to learn some core set of names, which isn't that small.
- I always (even unconsciously) try to obey to standard-library's naming conventions, therefore making my own function names hard to memorize.
Thanks for your answers!