<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7652.24">
<TITLE>RE: [plt-scheme] scribblings on PLT Scheme 4.0</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>Since I am certainly one of the set-car! and set-cdr! users that Jacob found in PLaneT, I guess I will weigh in on this one.<BR>
<BR>
One place I use them is when dealing with association lists. At a fundamental level, they just use cons cells as a two element structure (i.e., and 'association'). While it might have been better to explicitly create that structure, that isn't an option in R5RS from which we get association lists. In that case, set-car! and set-cdr! are essentially just field setters for associations. [There is also the matter of the actual list structure for the associations, but you get the idea.]<BR>
<BR>
I also use them, particularly in the Simulation Collection, for efficiency. Maintaining the various event lists and queues are a significant amount of the processing that takes place. I use set-cdr! in particular for efficiency there. A 2x performance hit would be significant. However, I also encapsulate all of that list manipulation (or mutilation, if you prefer) inside of my own modules to isolate them from user code.<BR>
<BR>
I have objections at all to having the standard list constructors make immutable lists - the vast majority of mine are. As long as I can create mutable lists where I need them, I'll be quite happy - particularly if I get some GC performance improvement from it.<BR>
<BR>
Doug<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: plt-scheme-bounces@list.cs.brown.edu on behalf of Matthew Flatt<BR>
Sent: Mon 5/28/2007 4:29 AM<BR>
To: Paulo J. Matos<BR>
Cc: plt-scheme@list.cs.brown.edu<BR>
Subject: Re: [plt-scheme] scribblings on PLT Scheme 4.0<BR>
<BR>
At Mon, 28 May 2007 11:17:52 +0100, "Paulo J. Matos" wrote:<BR>
> On 5/28/07, Matthew Flatt <mflatt@cs.utah.edu> wrote:<BR>
> > At Mon, 28 May 2007 09:44:38 +1000, Andrew Reilly wrote:<BR>
> > > I'm new to scheme myself, so I probably sholdn't have been<BR>
> > > making such liberal use of append! in my own code. I will<BR>
> > > repent...<BR>
> ><BR>
> > Do you used them for performance reasons?<BR>
> ><BR>
> > I used `append!' and `reverse!' a lot in my early Scheming, too,<BR>
> > because they were faster. It bit me often enough (no surprise) that I<BR>
> > decided to stay away, though there are certainly cases where mutating<BR>
> > versions work fine.<BR>
> ><BR>
><BR>
> I also use them for performance reasons sometimes. I use them for<BR>
> example when I want to sort a mapped list. I use (sort! (map f lst)).<BR>
> Or when I want to append a set of lists that results from map like<BR>
> (apply append! (map f lst)). I think using ! in these cases is good,<BR>
> afaik, because: 1. it's faster, 2. you know the list was just<BR>
> created, 3. you won't have problems.<BR>
<BR>
I agree that you won't have problems, as long as you know that `f'<BR>
doesn't capture any continuations to be applied after the `sort!' or<BR>
`append!'.<BR>
<BR>
How much time does `append!' save you in an actual application? My<BR>
guess is that the savings will be minor, but I'm interested in<BR>
measurements you might be able to take.<BR>
<BR>
Matthew<BR>
<BR>
_________________________________________________<BR>
For list-related administrative tasks:<BR>
<A HREF="http://list.cs.brown.edu/mailman/listinfo/plt-scheme">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</A><BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>