On Tuesday, 10 September 2013 at 10:53:15 UTC, Kenji Hara wrote:
On Tuesday, 10 September 2013 at 08:04:48 UTC, Namespace wrote:
Currently, all of array types does not allow copy-conversion
like ushort to short for their elements.
In old D1 age, static array did not have value semantics, so
the behavior was expected.
In D2, static array had changed to value type, but the
behavior was not changed.
As far as I know, there was no discussion about that, but at
least it is not fundamentally wrong.
Kenji Hara
And what is your personal opinion?
I think an implicit cast between signed / unsigned would be
acceptable even with static arrays. It were only logical.
Hmm, OK. I've taken a look a little deeper about the current
behavior.
void main()
{
void f1(short) {}
void f2(short[2]) {}
void f3(short[]) {}
ushort us = 1;
short ss = us; // OK
ss = us; // OK
f1(us); // OK
ushort[2] usa = [1,2];
short[2] ssa = usa; // OK -> [x]
ssa = usa; // NG -> [y]
f2(usa); // NG -> [y]
ushort[] uda = [1,2];
short[] sda = uda; // NG, expected
sda = uda; // NG, expected
f3(uda); // NG, expected
}
Surely the current state that, [x] is accepted but [y] is
rejected, looks weird to me. It would be a bug.
Kenji Hara
Nice to hear. I already filled a bug report:
http://d.puremagic.com/issues/show_bug.cgi?id=10999