Order of Static Construction
Dru
Dru at notreal.com
Fri Jan 4 18:53:37 UTC 2019
@Rubn
yes from the main thread
I'll give a specific example
lets say every thread has its own log
so log should be a thread local object
and lets say we want to log from a shared static ctor
log module
-----------
(define Log class ...)
Log log;
static this() {
log = new Log;
}
other module
-----------
import log_module;
(define other class ...)
shared Other other;
shared static this() {
log.write("creating other"); //seg fault log is null!
other = new Other;
}
@Neia Neutuladh
you're right the statement doesn't consider starting threads.
if we strictly follow the spec then yes it should error,
but I think maybe we should change the spec and mix between
shared/non-shared
if there isn't a good reason not to
More information about the Digitalmars-d
mailing list