Programming in D, page 155. shared static this() fails

monkyyy crazymonkyyy at gmail.com
Tue Jul 29 23:58:53 UTC 2025


On Tuesday, 29 July 2025 at 23:48:58 UTC, H. S. Teoh wrote:
> 
> `i` is immutable, so it's illegal to use mutating operations 
> like ~= on it.

@luna

The question should be if programming in d (page 177 
https://ddili.org/ders/d.en/Programming_in_D.pdf) should be 
authoritive here

> It is possible to mutate const and immutable variables in 
> shared static this()
blocks:

```d
import std.stdio;

immutable char[3] s;

shared static this() {
	s[0]='b';
     s[1]='a';
     s[2]='r';
}

void main(){
	writeln("In main()");
	writeln("s: ", s);
}
```
> Since      2.099.1: Success with output:

Im on op side now thinking whatever templated core.appender maybe 
partially unimplemented during the 100 changes


More information about the Digitalmars-d-learn mailing list