[racket] feedback on migrating to immutable pairs?

From: Ryan Newton (rrnewton at gmail.com)
Date: Mon Jun 28 22:44:27 EDT 2010

Pairs certainly should be immutable.  But I have to admit, I have run into a
lot of trouble with the transition.

I've got a DSL <http://wavescope.csail.mit.edu/>implemented in Scheme that I
run under Ikarus, Chez, and PLT.  It's been ported to R6RS and thus uses
mutable pairs.  I've had lots of trouble with this R6 code subsequently
interacting (with various degrees of intentionality) with non-R6 Racket

I needed to have some modules in Racket-proper for super-R6 functionality.
That's where I'd get into trouble.  Macros and eval uses that crossed this
boundary were painful.  For example I would have an eval handler, that would
get an environment sexp '(r6rs) that would violate its pair expectations.
Or I would have mixups involving which version of syntax->datum was used.

It may not have been a problem if the code were new, as opposed to porting a
legacy system.  Anyway, Matthew Flatt patiently helped me through my
brick-wall encounters.

By the way, is it on the horizon to have whole-program R6RS compiles that
will verify that no mutable pairs are used and select the immutable ones?
PLT seems to be the only R6 compiler in the position to do that...

Finally, mutable pairs are also cited as reason not to implement
deforestation in Scheme compilers.  I notice that R6 is
ban both list mutation in map's (irrespective of pairs mutability) and
leave evaluation order unspecified.  Does that mean we get deforestation


On Sun, Jun 13, 2010 at 11:26 AM, Sam Tobin-Hochstadt <samth at ccs.neu.edu>wrote:

> On Sun, Jun 13, 2010 at 2:51 AM, Neil Van Dyke <neil at neilvandyke.org>
> wrote:
> > 2. What was the rationale for not having "pair?", "car", "cdr", work on
> both
> > mutable pairs and immutable pairs?  Was this to push everyone harder
> towards
> > immutable pairs, at the cost of having to convert legacy libraries and
> > breaking R5RS compatibility?
> Having immutable and mutable pairs be distinct turns out to be very
> valuable for Typed Scheme/Racket.  Mutable pairs support more
> operations, so in one sense they should be subtypes of pairs in
> general.  But mutable pairs support fewer equations, and so cannot be
> used in places where immutable pairs are allowed, so cannot be treated
> as subtypes.  This makes the story for hashtables, vectors and boxes
> much more complex, and I'm happy that it's not the case for pairs.
> --
> sam th
> samth at ccs.neu.edu
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100628/b05c9628/attachment.html>

Posted on the users mailing list.