[plt-scheme] Mutable and immutable pairs in PLT Scheme

From: Robby Findler (robby at cs.uchicago.edu)
Date: Tue Nov 25 20:49:05 EST 2008

On Tue, Nov 25, 2008 at 6:44 PM, Andrew Reilly
<andrew-scheme at areilly.bpc-users.org> wrote:
> On Wed, Nov 26, 2008 at 12:09:19AM +0100, Thomas Chust wrote:
>> Basically, I think having immutable pairs as the default is a good
>> thing
>
> Me too.
>
> [snip]
>
>> things that I would consider bad programming practice. The proposal
>> would however greatly improve compatibility between libraries written in
>> R6RS and those written in PLT Scheme, since one could always work with
>> pairs returned from R6RS on the PLT Scheme side without problems and, in
>> many cases one could also pass PLT Scheme's immutable pairs to R6RS code
>> without causing trouble. And last but not least, I think this behaviour
>> would just feel more natural.
>
> I've just re-read Matthew's blog entry, as Robby suggested, and
> I regret that I didn't "get" why the type of mcons couldn't be a
> sub-type of cons, as a practical matter,

Of course, you can define a predicate that tests for both kinds of
cons's if you wanted, so in some sense this is really just a naming
issue.

The relevant lesson from Matthew's post is that when you write a
function that tests its arguments using `cons?' very often it breaks
if the pairs are mutable.

Of course, as Matthew has said many times, if you have experience
where these other sets of primitives make things substantially easier
(as opposed to opinions that this is the case -- we have no shortage
of all kinds of opinions around here :) we'd love to hear about it.

Robby


Posted on the users mailing list.