11 ms·
If I understand what you mean by "immutable by default", then it's all Scheme implementations, and probably all Lisp as well.
by 35bge57dtjku 10y ago
If I understand what you mean by "immutable by default", then it's all Scheme implementations, and probably all Lisp as well.
- nialo 10y agoCommon Lisp variables are not even a little bit immutable by default. setf is the opposite of immutable values, you can mutate any place in a way that's visible everywhere regardless of any sort of scoping. Immutable by default might be what you'd get if CL only had let to introduce/"change" variables.
- bakul 10y agoWhat about set-car! set-cdr! vector-set! string-set!
- dleslie 10y agoThey are discouraged by convention.
- 35bge57dtjku 10y agoIf you can't easily avoid those, you're not going to be capable of doing much else anyway.
- bakul 10y agoI was responding to "If I understand what you mean by "immutable by default", then it's all Scheme implementations"; not whether one should or should not use mutating operations!
- 35bge57dtjku 10y agoSo what does "immutable by default" mean??? Is there even an agreed upon definition? Because you certainly didn't explain / explain clearly if that's what you were attempting to do... Clojure has mutable vars and set!, so it seems Scheme is no worse and fits that guy's definition of IbD.
- bakul 10y agoConsider: (define x (vector 1 2 3 4)) (define y x) (vector-set! x 0 100) Should y[0] be 100 or 1?
- 35bge57dtjku 10y agoThat's not really relevant. According to the guy's own definition, Scheme is as immutable as Clojure, which is what he was specifically asking. They both have something like set!. If you want to wank off about Scheme not being 100% immutable, go right ahead, but it's clearly not what was being discussed.
- qwertyuiop924 10y agoScheme is always mutable, all the time, it just has separate functions for defining and mutating a variable.