3 ms·
Racket does support mutable pairs. http://docs.racket-lang.org/reference/mpairs.html?q=mcons#%28part._.Mutable_.Pair_.Constructors_and_.Selectors%29 http://doc
by soegaard 8y ago
Racket does support mutable pairs.
http://docs.racket-lang.org/reference/mpairs.html?q=mcons#%28part._.Mutable_.Pair_.Constructors_and_.Selectors%29 http://docs.racket-lang.org/reference/mpairs.html?q=mcons#%2...
- kazinator 8y agoThat's nice, but in Scheme, all pairs constructed by any code anywhere are mutable, and structure made out of mutable pairs can be passed into any library function. An object notation like (a b c) read from a stream gives you a mutable object. It's a significant language difference that can't be papered over with a data type and handful of functions.
- soegaard 8y agoThat's a different concern. Racket supports both immutable and mutable cons cells. Convenient or not - you decide. Oh, been watching too much YouTube. In both Racket and Scheme it is usually a good idea to program in a functional style - i.e. not to mutate pairs. The compiler and runtime system can in some situations handle immutable pairs more efficiently than mutable pairs. So if mutable pairs are seldomly used, it makes sense to make immutable pairs the default. The rationale why Racket made the shift is described here: http://blog.racket-lang.org/2007/11/getting-rid-of-set-car-and-set-cdr.html http://blog.racket-lang.org/2007/11/getting-rid-of-set-car-a... In short: the Racket community sees the immutable default as a plus.