Run-time setting of immutable variable?

DLearner bmqazwsx123 at gmail.com
Fri Sep 3 08:44:58 UTC 2021


On Thursday, 2 September 2021 at 23:12:28 UTC, Steven 
Schveighoffer wrote:
>
[...]
> immutable means "I can never change and *everything I point at* 
> can never change".
[...]

If that is how the language defines the keyword 'immutable' when 
used in the definition of a pointer variable, then so be it.

I would, however, suggest that the additional 
'action-at-a-distance' implication (freezing not just the 
variable itself, but also it's target) is inconsistent with the 
definition of 'immutable' with other variable types.

Surely it would be better to reserve 'immutable' on a pointer to 
mean simply set-once on the pointer itself (with no implications 
for whatever the pointer is pointing to), and another keyword 
('blocked'?) for the current definition?




More information about the Digitalmars-d-learn mailing list