Mutable reference for immutable AA
Jack Applegame via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri May 29 04:42:35 PDT 2015
I need mutable storage for immutable associative array. Just
create new immutable AA and store it for future passing it
between threads/fibers.
First attempt: just immutable AA
immutable aa = ["1":1, "2":1];
aa = ["1":1, "2":1]; // fail, can't assign a new AA
Second attempt: mutable AA with immutable elements.
immutable (int)[string] aa = ["1":1, "2":1];
aa = ["1":1, "2":1]; // sucess!
aa["2"] = 2; // doesn't compile, is AA immutable?
aa.remove("1"); // fail, this compiles, AA actually isn't
immutable
Third attempt: Rebindable
Rebindable!(immutable int[string]) aa; // fail, Rebindable
doesn't accept AAs
More information about the Digitalmars-d-learn
mailing list