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

From: Andrew Reilly (andrew-scheme at areilly.bpc-users.org)
Date: Tue Nov 25 19:44:58 EST 2008

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.


> 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, but I can see why you
wouldn't want them to be, from the perspective of the experiment
performed in PLT 4.0.

However, the issue of compatability would seem to be a
significant one, and perhaps a major reason why one wouldn't
want to write or introduce R6RS libraries as standard elements
of the PLT system, or find them on PLaneT: PLT4.0 code wouldn't
want to have a bunch of wrappers to translate result mlists
into normal lists.  However, given the result of the PLT4.0
experiment, wouldn't it be possible for PLT-hosted R6RS
libraries to have switchable behaviour with respect to cons
cells, depending on whether or not they import the set-car!
and set-cdr! functions?  That is, one would expect that most
modern R6RS libraries would *not* import these, and so could
happily assume immutable cons behaviour, and so could happily
interact with #lang/scheme modules on an equal footing?  Maybe
that is how it is already: I haven't tried to convert any of my
code to R6RS style, but am intrigued by the possibility that I
should, one day.  But since it already works happily without
mcons, I would prefer to not have to do anything special in
R6RS to get the same behaviour.  I'm in no hurry to change,
though: I've been getting some good milage from module contracts
in PLT-land.



Posted on the users mailing list.