[plt-scheme] scribblings on PLT Scheme 4.0

From: Shriram Krishnamurthi (sk at cs.brown.edu)
Date: Sun May 27 22:27:22 EDT 2007

On 5/27/07, Bill Wood <william.wood3 at comcast.net> wrote:
>
> But there's space efficiency to be considered as well as time, isn't
> there?  There's a lot of consing going on with the pure variants.

If you have no other references to the same cons cells, then the GC
will (eventually) make sure you use no additional space.  If you do
have other references to the same cons cells, then you've perhaps
inadvertently destroyed invariants that those other references depend
upon; as Matthew said,

  I used `append!' and `reverse!' a lot in my early Scheming, too,
  because they were faster. It bit me often enough (no surprise) that
  I decided to stay away

So you should really only use the ! versions if you can either be
*sure* there are no other references (and, more importantly, that
there will not be other references in future versions!), or you *want*
those other references to see the changes.  If you cannot be certain
that you firmly land, now and for the foreseeable future, in one of
these two categories, why take the risk?

Shriram


Posted on the users mailing list.