[Issue 18100] crt_constructor not allow to init immutable

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Dec 20 14:13:57 UTC 2017


https://issues.dlang.org/show_bug.cgi?id=18100

--- Comment #4 from Steven Schveighoffer <schveiguy at yahoo.com> ---
(In reply to changlon from comment #3)
> Since better D is target for high performance low level code, we should
> allow set immutable on crt_constructor, or drop crt_constructor and support
> static share this.

It is allowed, you just cast :) We do it in druntime and it works fine. As long
as your immutable isn't initialized, the compiler treats it as a variable when
using it elsewhere.

See here: https://github.com/dlang/druntime/blob/master/src/core/time.d#L2429

It's on you to make sure it isn't called elsewhere. What I don't want is to
create a hole in const/immutable in the language. I'd rather you create the
hole, and then guard it yourself.

There are other reasons not to use shared static this to mean something
different than "properly ordered static constructors" if they are tagged with
extern(C) or some pragma.

--


More information about the Digitalmars-d-bugs mailing list