Thread overview
std.typecons.Rebindable
Jan 31, 2014
Jack Applegame
Jan 31, 2014
Frustrated
Jan 31, 2014
monarch_dodra
Feb 02, 2014
Jack Applegame
January 31, 2014
Why doesn't Rebindable allow associative arrays?

import std.typecons;

Rebindable!(immutable string[]) data1;       // ok
Rebindable!(immutable string[string]) data2; // error
January 31, 2014
On Friday, 31 January 2014 at 08:40:30 UTC, Jack Applegame wrote:
> Why doesn't Rebindable allow associative arrays?
>
> import std.typecons;
>
> Rebindable!(immutable string[]) data1;       // ok
> Rebindable!(immutable string[string]) data2; // error

an associative array doesn't pass the isArray test

isArray!(string[]) // true
isArray!(string[string]) // false

Not sure if there is some inherent reason why but I would venture
to say it is a bug.
January 31, 2014
On Friday, 31 January 2014 at 12:43:21 UTC, Frustrated wrote:
> On Friday, 31 January 2014 at 08:40:30 UTC, Jack Applegame wrote:
>> Why doesn't Rebindable allow associative arrays?
>>
>> import std.typecons;
>>
>> Rebindable!(immutable string[]) data1;       // ok
>> Rebindable!(immutable string[string]) data2; // error
>
> an associative array doesn't pass the isArray test
>
> isArray!(string[]) // true
> isArray!(string[string]) // false
>
> Not sure if there is some inherent reason why but I would venture
> to say it is a bug.

What's the point of using Rebindable for a non-[class|interface]
type? They are the only type where it makes sense, since you
can't give different qualifiers to the handler and the object.

I'm surprised it even handles arrays at all. As a matter of fact,
the documentation says:
"However, Rebindable!(T) does not compile if T is a non-class
type."
If arrays worked, I think it was buggy behavior. There's no sense
in having a Rebindable array.
February 02, 2014
> What's the point of using Rebindable for a non-[class|interface]
> type? They are the only type where it makes sense, since you
> can't give different qualifiers to the handler and the object.
>
> I'm surprised it even handles arrays at all. As a matter of fact,
> the documentation says:
> "However, Rebindable!(T) does not compile if T is a non-class
> type."
> If arrays worked, I think it was buggy behavior. There's no sense
> in having a Rebindable array.
Hmm. I need to pass an unique associative array to several threads. If this array has immutable elements, but isn't immutable itself, then what happen if one of threads adds or removes element from array?
Associative arrays is some kind of hash-table. Adding alements in one thread can cause undefined behaviour in other thread.
Am I wrong?