Reconciling mutable collections scgmille@xxxxxx (29 Jul 2003 03:31 UTC)
Re: Reconciling mutable collections Matthias Radestock (29 Jul 2003 06:57 UTC)

Re: Reconciling mutable collections Matthias Radestock 29 Jul 2003 06:57 UTC

xxxxxx@freenetproject.org wrote:

> Purely mutable collections would return #t from mutable-collection?, and
> when present, an additional form of each update procedure would exist
> and would be defined on that collection, such as *-add!!.  The procedure
> takes a collection as input and its return value is undefined.  *-add!
> and *-add would also still be defined.  *-add may require cloning to
> operate, and *-add! could be equivalent to *-add!!, but would return the
> input collection as output.

Great! One minor tweak: The !! operations should return the collection,
thus aligning their type signatures with that of the ! and non-! operations.

An alternative to !! would be to specify that when mutable-collection?
returns #t the ! procedures have mutating behaviour rather than updating
behaviour. The drawback is that this makes it less obvious (to humans
and the Scheme) whether code is relying on the mutability, and hence
could be error-prone. The advantage is that it avoids a whole set of new
operations that are redundant when defined (i.e. I can't think of any
case where !!, when defined for a specific collection, would return a
different result from !).

Matthias.