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

--- Comment #4 from Steven Schveighoffer <[email protected]> ---
(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.

--

Reply via email to