Mutation
Harvey J. Stein
abel@netvision.net.il
Wed, 14 May 1997 12:06:27 +0300
Mike McDonald writes:
>
> From: BRIAN SPILSBURY <zhivago@iglou.com>
>
> >(make-array (length foo) :allocation immutable :generator
> > `(lambda (i) (nth i ,foo)))
> >
> >to initialize from a list.
>
> Why not just use the :initial-contents keyword?
Because one would have to generate a list for the contents, just so it
gets thrown away after creating the array, thus being an additional
source of garbage. Henry Baker already mentioned this approach:
> Another approach is to create a brand new functional array by copying
> an existing mutable array. This solves the problem of bad semantics,
> but forces you to throw away and GC a perfectly good mutable array for
> every immutable array. So we have good semantics, but bad performance.
--
Harvey J. Stein
Berger Financial Research
abel@netvision.net.il