digitalmars.D.learn - Associative arrays, multithreading, Rebindable
- Jack Applegame (21/21) Apr 12 2014 If I want to pass a dynamic array from one thread to another,
- bearophile (4/5) Apr 12 2014 I guess so. But how to implement it?
- Jack Applegame (2/7) Apr 12 2014 May be just like Rebindable for classes?
- monarch_dodra (5/10) Apr 12 2014 Related: "Rebindable supports arrays (Which makes no sense)"
If I want to pass a dynamic array from one thread to another, then I use immutable(T)[] and it is safe. But what if I need to pass an associative array? I suppose that the use of immutable(T)[U] is unsafe. Because one thread can delete the entry and this will have an impact also on the instance of the array in another thread. So I have to use immutable(T[U]). But the immutability of the entire array makes the array reference immutable too: immutable int[string] foo; foo = assumeUnique(other); // error For immutable classes we can use std.typecons.Rebindable: Rebindable!(immutable Foo) foo; foo = new immutable Foo; // fine But for immutable associative arrays we can't: Rebindable!(immutable int[string]) foo; // error foo = assumeUnique(other); Error: template instance std.typecons.Rebindable!(immutable(int[string])) does not match template declaration Rebindable(T) if (is(T == class) || is(T == interface) || isArray!T) Should Rebindable to support associative arrays?
Apr 12 2014
Jack Applegame:Should Rebindable to support associative arrays?I guess so. But how to implement it? Bye, bearophile
Apr 12 2014
On Saturday, 12 April 2014 at 09:18:12 UTC, bearophile wrote:Jack Applegame:May be just like Rebindable for classes?Should Rebindable to support associative arrays?I guess so. But how to implement it? Bye, bearophile
Apr 12 2014
On Saturday, 12 April 2014 at 09:18:12 UTC, bearophile wrote:Jack Applegame:Related: "Rebindable supports arrays (Which makes no sense)" https://issues.dlang.org/show_bug.cgi?id=12046 Quote: "It *might* make sense with associative arrays though... Not sure"Should Rebindable to support associative arrays?I guess so. But how to implement it? Bye, bearophile
Apr 12 2014