This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home.

Source for wiki ImmutableData version 1

author

medernac

comment

Immutable data

ipnr

88.177.167.25

name

ImmutableData

readonly

0

text

== Immutable data ==

Why not having a distinct 'immutable' data type, containing a value
which cannot be mutated, and an associated function which creates copy
of the immutable data at each call ?

`(make-immutable data)`

  Returns an immutable data containing a copy of data.

`(immutable? obj)`

  Returns #t if obj is an immutable, otherwise returns #f.

`(immutable->copy obj)`

  This is an error if obj is not an immutable, else it returns a copy of the data contained in obj.

=== Note ===

Of course it is impossible to mutate the value contained inside an 'immutable' object, however the 'immutable' object itself could be mutated. For instance it is possible to mutate a variable containing an 'immutable' object, or a list containing 'immutable' objects but not a list contained inside an 'immutable' object.

time

2010-11-13 17:58:30

version

1