Hi Ian! Ian Price <ianpric...@googlemail.com> writes:
> Mark H Weaver <m...@netris.org> writes: > >> As I understand it, in the Scheme standards (at least before R6RS's >> immutable pairs) the rationale behind marking literal constants as >> immutable is solely to avoid needlessly making copies of those literals, >> while flagging accidental attempts to modify them, since that is almost >> certainly a mistake. > Erm, if you don't count literals, which were already immutable, then > R6RS doesn't have immutable pairs. It does move the mutators to a > separate module, but that is a not really equivalent, because even if > you don't import (rnrs mutable-pairs), another module may mutate pairs > returned by your library. Ditto for strings,etc. > > To quote section 5.10 > "Literal constants, the strings returned by symbol->string, records with > no mutable fields, and other values explicitly designated as immutable > are immutable objects, while all objects created by the other procedures > listed in this report are mutable." Ah, I guess you're right. I never studied the R6RS carefully outside of its handling of numerics. I wrote "at least before R6RS" to indicate that I was only knowledgeable about earlier versions. Racket's immutable pairs represent a break in the older tradition. Last I looked anyway, Racket's mutable pairs cannot even be accessed with the standard `car' and `cdr'. Therefore, they really are a different (and incompatible) type from mutable pairs. I still suspect that the rationale behind immutable pairs in the R6RS is to discourage mutation of pairs, to give compiler implementations such as Racket the freedom to make pairs truly immutable as thus benefit from better optimizer. However, I mistakenly implied that immutable pairs were a distinct type in the R6RS itself, and for that I apologize. Thanks, Mark