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

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.

Matthias raised some concerns about the collection making 'purely 
mutable', i.e. collections who can only be updated through side effects, 
and for which (eq? old new) is always #t.  

After some discussion on #scheme, this proposal came out.

Mutability would be come an attribute of collections, just as
orderedness is at the moment.  Attributes inform the programmer when 
certain functions are defined.  For example, collection-fold-right is 
defined when ordered-collection? returns #t.  

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.  

This is necessary in order to both support purely mutable collections 
and to allow portable code to be written to such collections and still 
be efficient in the absence of an omniscient compiler.  Furthermore, the 
programmer need not know that a specific collection is being used, only 
that its mutable.

Attachment: pgpeNbi0USS0M.pgp
Description: PGP signature