[plt-scheme] The historical role/value of set-car! and set-cdr!
Grant Rettke wrote:
> Historically, though, [set-car! and set-cdr!] must have been there for some really good reason?
>
> What was that reason?
In addition to some of the responses posted already:
Early Lisp didn't have "structs" or any other mechanism for representing
compound data. So lists were it. Philosophically, a pair is the
simplest possible compound data structure, and you can build any other
compound structure out of them, so they had a great power-to-weight
ratio for a small language on an early machine.
Now that PLT Scheme has structs and vectors and objects, which support
mutation, there's no need to use lists for those purposes. Not much is
actually being eliminated here, but the purpose of lists has been
narrowed and some of their functionality shifted elsewhere.
In another situation, it might have made more sense to introduce a new
type of immutable list, which wouldn't affect old code. However,
because the use of lists is embedded at a low level in Scheme, e.g. as
the arguments to the 'apply' function and the type of the value that's
used in procedures with variable numbers of arguments, there's a benefit
implementations for making the existing list type immutable.
Anton