Mutation
Andrew Justin Blumberg
blumberg@ai.mit.edu
Tue, 13 May 1997 18:58:34 -0400 (EDT)
>
> > Regarding the use of mutation, isn't it pretty common once you start
> > using arrays? When doing large data analyses in Lisp, I've had to
> > replace lists of numbers with typed arrays, and changed computations
> > to all work in place so as to reduce garbage creation. This is to
> > increase efficiency, and often helps alot (can give a factor of 2 or 3
> > speedup, or even make an intractible problem tractible). What sort of
> > effects are the anti-mutation proposals going to have on this?
> >
> > --
> > Harvey J. Stein
>
> The problem with functional objects is indeed functional arrays. You
> have to have some way to initialize them. One way to do this is to
> have them start life as mutable arrays, and then at some point you
> 'freeze' them into immutable arrays. The problem with this approach
> is that it 'surprises' the person still holding onto a pointer to the
> old 'mutable' array. These semantics are very unpleasant because they
> violate the constancy of type.
consider the following situation :
i'm reading text into a buffer. i'm going to want to compute based on the
text, but i don't want to keep it. thus, when processing a lot of files i
use a single buffer and write over it repeatedly to cut down on gratuitous
consing.
how would this be resolved in a functional object framework?
- andrew