Member access of __gshared global object
Dragos Carp via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Aug 6 08:18:14 PDT 2014
On Wednesday, 6 August 2014 at 14:36:23 UTC, Marc Schütz wrote:
>
> This would defeat the purpose, see the original post.
sorry, I red just the last post.
__gshared has no influence on this.
> auto cmds = CONFIG.commands;
> cmds["list"] = new Command(...);
cmds is a thread local variable referencing the shared AA. But if
you add new elements to cmds, cmd will be reallocated and the
shared AA will remain unchanged. Though, updated values of
existing keys will be visible in the original, because no
relocation takes place.
If you want to change the original you need a pointer or a
reference (for a setter function).
auto cmds = &CONFIG.commands;
(*cmds)["list"] = new Command(...);
More information about the Digitalmars-d-learn
mailing list