Concatenation of ubyte[] to char[] works, but assignation doesn't
Ola Fosheim Grøstad via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Oct 6 05:13:37 PDT 2015
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 (i.e. loss of
> precision) for ints, so it's a bit inconsistent to disallow it
> for chars.
Yes, D does not have overflow, it has modular arithmetics. So the
same argument would hold for an enumeration (like character
ranges), do you want them to be modular (a circle) or monotonic
(a line). Neither is a good fit for unicode. It probably would
make most sense to split the unicode universe into multiple typed
ranges, some enumerations, some non-enumerations and avoid char
altogether.
More information about the Digitalmars-d-learn
mailing list