[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reconciling mutable collections

This page is part of the web mail archives of SRFI 44 from before July 7th, 2015. The new archives for SRFI 44 contain all messages, not just those from before July 7th, 2015.



scgmille@xxxxxxxxxxxxxxxxxx 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.