[racket] feedback on migrating to immutable pairs?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun Jun 13 08:49:25 EDT 2010

At Sun, 13 Jun 2010 02:51:44 -0400, Neil Van Dyke wrote:
> 1. Does anyone have feedback on how that went?  (The only problems I 
> recall dealing with personally were pain for HtmlPrag, a minor change to 
> the "csv" library, and a small headache supporting SICP.)

For the Racket (then PLT Scheme) tree, there was some brief pain in
converting code that uses `set-car!' and `set-cdr!' to different data
structures. In all cases, the change was local (i.e., no contracts had
to change, other than the change in meaning of "pair" and "list").

Reduced interoperability between Racket libraries and R5RS/R6RS code
was the one big hit.

> 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 `pair?' and `list?' recognize data constructed without mutable
pairs would have missed the point of the change. The point was that
existing code that uses `pair?' and `list?' almost always intended
`pair-that-wont-change-while-i-am-looking?' and `list-that-will-
stay-a-list-until-i-am-done?'. Having `pair?' recognize mutable pairs
would not have given us the intended benefit of the change.

Posted on the users mailing list.