Lazily Initialized Variables that are Compatible with const/immutable
Ali Çehreli
acehreli at yahoo.com
Thu Nov 17 13:50:04 UTC 2022
On 11/17/22 02:57, Vijay Nayar wrote:
> Is there another way to perform lazy initialization that is compatible
> with const/immutable, or is this needed as a language feature?
If the variable needs to be shared, there is a library solution:
https://dlang.org/phobos/std_concurrency.html#.initOnce
And here is a user of initOnce():
https://github.com/dlang/phobos/blob/master/std/parallelism.d#L3569
Ali
More information about the Digitalmars-d
mailing list