4 ms·
"lazy" and "immutable" are orthogonal. "lazy" happily co-exists with "mutable". TXR Lisp has mutable lazy conses: 1> (take 12 (range 1)) (1 2 3 4 5 6 7 8 9
by kazinator 8y ago
"lazy" and "immutable" are orthogonal. "lazy" happily co-exists with "mutable". TXR Lisp has mutable lazy conses:
1> (take 12 (range 1))
(1 2 3 4 5 6 7 8 9 10 11 12)
2> (let ((r (range 1)))
(inc [r 4] 15)
(take 12 r))
(1 2 3 4 20 6 7 8 9 10 11 12)
There is no reason to prevent mutation; all we have to do is assume that programmers are grownups and treat them as such.
Remember, mutate responsibly; if you mutate, don't derive.
Even if someone has been mutating "harmless" local variables, do not jump into the same lexical scope with them.