[plt-scheme] scribblings on PLT Scheme 4.0

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon May 28 06:29:44 EDT 2007

At Mon, 28 May 2007 11:17:52 +0100, "Paulo J. Matos" wrote:
> On 5/28/07, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> > At Mon, 28 May 2007 09:44:38 +1000, Andrew Reilly wrote:
> > > I'm new to scheme myself, so I probably sholdn't have been
> > > making such liberal use of append! in my own code.  I will
> > > repent...
> >
> > Do you used them for performance reasons?
> >
> > 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, though there are certainly cases where mutating
> > versions work fine.
> >
> 
> I also use them for performance reasons sometimes. I use them for
> example when I want to sort a mapped list. I use (sort! (map f lst)).
> Or when I want to append a set of lists that results from map like
> (apply append! (map f lst)). I think using ! in these cases is good,
> afaik,  because: 1. it's faster, 2. you know the list was just
> created, 3. you won't have problems.

I agree that you won't have problems, as long as you know that `f'
doesn't capture any continuations to be applied after the `sort!' or
`append!'.

How much time does `append!' save you in an actual application? My
guess is that the savings will be minor, but I'm interested in
measurements you might be able to take.

Matthew



Posted on the users mailing list.