This concerns the discussion in #74, #80, #192, #278, and #296.
In the R6RS, literal constants should raise an exception on modificiation:
It is desirable for constants(i.e. the values of literal expressions) to reside in read-only memory. To express this, it is convenient to imagine that every object that refers to locations is associated with a flag telling whether that object is mutableor immutable. Literal constants, the strings returned by symbol->string, records with no mutable fields, and other values explicitly designated as immutable are immutable objects, while all objects created by the other procedures listed in this report are mutable. An attempt to store a new value into a location referred to by an immutable object should raise an exception with condition type &assertion.
In the R7RS, it is an error:
Every object that denotes locations is either mutable or immutable. Literal constants, the strings returned by symbol->string, and possibly the environment returned by scheme-report-environment are immutable objects. All objects created by the other procedures listed in this report are mutable. It is an error to attempt to store a new value into a location that is denoted by an immutable object.
[...]
Rationale: In many systems it is desirable for constants (i.e. the values of literal expressions) to reside in read-only memory. Making it an error to alter constants permits this implementation strategy, while not requiring other systems to distinguish between mutable and immutable objects.
On the Stygian Blue docket, enforcement of immutability of literal values was voted down. SRFI 116, immutable lists, was removed in the Stygian Blue docket, and SRFI 101 may be removed at a later point in time. So immutable variants (or possibly disjoint types) of standard Scheme objects are mostly out.
I propose we keep the status quo of R6RS/R7RS, where mutation of an immutable object is undefined behavior which should raise an exception, and there is no way of differentiating mutable and immutable objects. I think this is the only sensible way forward, given the constraints of the votes. It will also address all of the immutability issues above (since we go with the status quo).
Proposed wording (new wording in bold, based off of R7RS):
Every object that denotes locations is either mutable or immutable. Literal constants, (削除) the strings returned by symbol->string, (削除ここまで) records with no mutable fields and (削除) possibly the environment returned by scheme-report-environment (削除ここまで) other values explicitly designated as immutable are immutable objects. All objects created by the other procedures listed in this report are mutable. It is (削除) an error (削除ここまで) undefined behavior to attempt to store a new value into a location that is denoted by an immutable object. An attempt to store a new value into a location referred to by an immutable object should raise an exception.
[...]
Rationale: In many systems it is desirable for constants (i.e. the values of literal expressions) to reside in read-only memory. Making it (削除) an error (削除ここまで) undefined behavior to alter constants permits this implementation strategy, while not requiring other systems to distinguish between mutable and immutable objects.
- The part about
symbol->string and scheme-report-environment is covered by "other values explicitly designated as immutable."
- The part about the exception will depend on what form the exception system will take.
This concerns the discussion in #74, #80, #192, #278, and #296.
In the R6RS, [literal constants should raise an exception on modificiation](https://r6rs.org/final/html/r6rs/r6rs-Z-H-8.html#node_sec_5.10):
> It is desirable for constants(i.e. the values of literal expressions) to reside in read-only memory. To express this, it is convenient to imagine that every object that refers to locations is associated with a flag telling whether that object is mutableor immutable. Literal constants, the strings returned by symbol->string, records with no mutable fields, and other values explicitly designated as immutable are immutable objects, while all objects created by the other procedures listed in this report are mutable. An attempt to store a new value into a location referred to by an immutable object should raise an exception with condition type &assertion.
In the R7RS, [it is an error](https://standards.scheme.org/r7rs-html5/index.html#3.4):
> Every object that denotes locations is either mutable or immutable. Literal constants, the strings returned by symbol->string, and possibly the environment returned by scheme-report-environment are immutable objects. All objects created by the other procedures listed in this report are mutable. It is an error to attempt to store a new value into a location that is denoted by an immutable object.
>
> [...]
>
> Rationale: In many systems it is desirable for constants (i.e. the values of literal expressions) to reside in read-only memory. Making it an error to alter constants permits this implementation strategy, while not requiring other systems to distinguish between mutable and immutable objects.
On the Stygian Blue docket, [enforcement of immutability of literal values](https://codeberg.org/scheme/r7rs/src/branch/main/ballot-results/dpk/2025-03-stygian-blue-reddish-green-report.md#1-should-r7rs-large-require-implementations-to-enforce-the-immutability-of-literal-values) was voted down. [SRFI 116](https://srfi.schemers.org/srfi-116/), immutable lists, was removed in the Stygian Blue docket, and [SRFI 101](https://srfi.schemers.org/srfi-101/) may be removed [at a later point in time](https://codeberg.org/scheme/r7rs/src/branch/main/ballot-results/dpk/2025-03-stygian-blue-reddish-green-report.md#5-should-r7rs-large-ultimately-include-only-one-of-list-queues-a-k-a-tconcs-srfi-117-scheme-list-queue-from-the-red-edition-random-access-lists-srfi-101-scheme-rlist-from-the-red-edition-flexvectors-srfi-214-persistent-growable-vectors-no-srfi-yet-or-finger-trees-no-srfi-yet). So immutable variants (or possibly disjoint types) of standard Scheme objects are mostly out.
I propose we keep the status quo of R6RS/R7RS, where mutation of an immutable object is undefined behavior which should raise an exception, and there is no way of differentiating mutable and immutable objects. I think this is the only sensible way forward, given the constraints of the votes. It will also address all of the immutability issues above (since we go with the status quo).
________________________
Proposed wording (new wording in bold, based off of R7RS):
> Every object that denotes locations is either mutable or immutable. Literal constants, ~~the strings returned by symbol->string,~~ **records with no mutable fields** and ~~possibly the environment returned by scheme-report-environment~~ **other values explicitly designated as immutable** are immutable objects. All objects created by the other procedures listed in this report are mutable. It is ~~an error~~ **undefined behavior** to attempt to store a new value into a location that is denoted by an immutable object. **An attempt to store a new value into a location referred to by an immutable object should raise an exception.**
>
> [...]
>
> Rationale: In many systems it is desirable for constants (i.e. the values of literal expressions) to reside in read-only memory. Making it ~~an error~~ **undefined behavior** to alter constants permits this implementation strategy, while not requiring other systems to distinguish between mutable and immutable objects.
1. The part about `symbol->string` and `scheme-report-environment` is covered by "other values explicitly designated as immutable."
2. The part about the exception will depend on what form the exception system will take.