[plt-scheme] scribblings on PLT Scheme 4.0
On Sun, 2007-05-27 at 22:27 -0400, Shriram Krishnamurthi wrote:
> 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?
I plead noli contendere as far as the general safety consideration goes,
and I've written a lot of CL with that in mind. The fact is, I rarely
do list surgery. However, it is a good thing that the capability is
there when/if careful, knowledgeable consideration deems it's use
appropriate. It seems to me that space efficiency can lead in that
direction, although somewhat less frequently now than in the days of
kiloword memory :-). Speaking of which, in 1985 I found a really nice
lisp implementation, Franz-like, including reader macros with splicing,
for an 8080/Z80-based computer (64K bytes!). Well-documented too. I
was impressed.
-- Bill Wood