Re:On Lisp
by chongli on Monday August 26, 2013 @02:30AM
(#6275505)
A fair amount of the examples involve mutation; a practice that Clojure discourages. A lot of the macros are very instructive, however.
[ Parent
| on HN ]
Indeed, On Lisp has an excellent discussion of
mutation and its use in programs written in a functional style. In discussing destructive functions, Graham describes the ways in which they can be used with reasonable safety - e.g. immediately mutating a list newly created by a mapping function.
The reasons one might do so in Clojure are likely to bear similarity to those provided by Graham - speed and memory - despite the vastly greater resources of today's computers versus those of 1991.
Very good point. Mutation is extremely useful when birthing a new data structure; this is a time when it's not yet visible to the rest of the system so the danger of sharing intermediate state does not occur. Clojure has a very elegant facility for dealing with this particular scenario: