Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-06 Thread Marc Schütz via Digitalmars-d-learn
On Tuesday, 6 October 2015 at 05:38:36 UTC, Jonathan M Davis wrote: Your suggestion only works by assuming that the result will fit in a char, which doesn't fit at all with how coversions are currently done in D. It would allow for narrowing conversions which lost data. And there's no way that

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-06 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 6 October 2015 at 09:28:29 UTC, Marc Schütz wrote: I see, this is a new problem introduced by `char + int = char`. But at least the following could be disallowed without introducing problems: int a = 'a'; char b = 32; But strictly speaking, we already accept overflow

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 06, 2015 09:28:27 Marc Schütz via Digitalmars-d-learn wrote: > I see, this is a new problem introduced by `char + int = char`. > But at least the following could be disallowed without > introducing problems: > > int a = 'a'; > char b = 32; Sure, it would be nice, but

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, October 05, 2015 11:48:51 Marc Schütz via Digitalmars-d-learn wrote: > On Monday, 5 October 2015 at 10:30:02 UTC, Jonathan M Davis wrote: > > On Monday, October 05, 2015 09:07:34 Marc Schütz via > > Digitalmars-d-learn wrote: > >> I don't think math would be a problem. There are some

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-05 Thread skilion via Digitalmars-d-learn
On Sunday, 4 October 2015 at 21:57:44 UTC, Jonathan M Davis wrote: When appending, b to a, the elements in b are being copied onto the end of a, and presumably it works in this case, because a ubyte is implicitly convertible to char. But all it's doing is converting the individual elements.

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-05 Thread Marc Schütz via Digitalmars-d-learn
On Sunday, 4 October 2015 at 21:57:44 UTC, Jonathan M Davis wrote: On Sunday, October 04, 2015 16:13:47 skilion via Digitalmars-d-learn wrote: Is this allowed by the language or it is a compiler bug ? void main() { char[] a = "abc".dup; ubyte[] b = [1, 2, 3]; a = b; // cannot

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, October 05, 2015 09:07:34 Marc Schütz via Digitalmars-d-learn wrote: > On Sunday, 4 October 2015 at 21:57:44 UTC, Jonathan M Davis wrote: > > On Sunday, October 04, 2015 16:13:47 skilion via > > Digitalmars-d-learn wrote: > >> Is this allowed by the language or it is a compiler bug ? >

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-05 Thread Marc Schütz via Digitalmars-d-learn
On Monday, 5 October 2015 at 10:30:02 UTC, Jonathan M Davis wrote: On Monday, October 05, 2015 09:07:34 Marc Schütz via Digitalmars-d-learn wrote: I don't think math would be a problem. There are some obvious rules that would likely just work with most existing code: char + int = char char -

Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-04 Thread skilion via Digitalmars-d-learn
Is this allowed by the language or it is a compiler bug ? void main() { char[] a = "abc".dup; ubyte[] b = [1, 2, 3]; a = b; // cannot implicitly convert expression (b) of type ubyte[] to char[] a ~= b; // works }

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 04, 2015 16:13:47 skilion via Digitalmars-d-learn wrote: > Is this allowed by the language or it is a compiler bug ? > > void main() { > char[] a = "abc".dup; > ubyte[] b = [1, 2, 3]; > a = b; // cannot implicitly convert expression (b) of type > ubyte[] to char[]