Thread overview | ||||||
---|---|---|---|---|---|---|
|
January 31, 2014 std.typecons.Rebindable | ||||
---|---|---|---|---|
| ||||
Why doesn't Rebindable allow associative arrays? import std.typecons; Rebindable!(immutable string[]) data1; // ok Rebindable!(immutable string[string]) data2; // error |
January 31, 2014 Re: std.typecons.Rebindable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jack Applegame | 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 Re: std.typecons.Rebindable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frustrated | 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 Re: std.typecons.Rebindable | ||||
---|---|---|---|---|
| ||||
Posted in reply to monarch_dodra | > 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?
|
Copyright © 1999-2021 by the D Language Foundation