On 10/28/20 3:07 PM, H. S. Teoh wrote:
A shared immutable is initialized at compile-time,
To prevent a misunderstanding, immutable can be initialized at run time as well. On the other hand, immutable initialized at compile time was surprising to me when I learned it recently:
import std; immutable string p; shared static this() { p = environment["PATH"]; // <-- Run time } // Ali learned this relatively recently // (immutable at compile time): immutable lines = import("myfile.txt").splitter('\n').array; pragma(msg, lines); void main() { } Ali