On Fri, Feb 04, 2022 at 03:58:19PM +0000, Stanislav Blinov via Digitalmars-d-learn wrote: [...] > As others have already stated, casting immutability away is something > that has to be supported, e.g. to interface with const-agnostic APIs. > `@safe` requires such casts to be more verbose, with good reason.
Not to mention, casting to/from immutable is necessary in order to be able to implement D's GC in D. Basically, a cast is equivalent to telling the compiler "I know what I'm doing, don't complain". Generally casts should be avoided except under special circumstances. T -- Fact is stranger than fiction.