Annoyance with new integer promotion deprecations
Dmitry Olshansky
dmitry.olsh at gmail.com
Wed Feb 7 06:16:32 UTC 2018
On Monday, 5 February 2018 at 20:45:22 UTC, H. S. Teoh wrote:
> On Mon, Feb 05, 2018 at 03:23:20PM -0500, Steven Schveighoffer
> via Digitalmars-d wrote:
>> On 2/5/18 2:30 PM, H. S. Teoh wrote:
>> > Even better yet:
>> >
>> > byte b;
>> > b = -b; // Deprecation error
>> >
>> > WAT????
>>
>> In the future, -b will be typed as an int, so you can't
>> reassign it to b. You can see this today with
>> -transition=intpomote:
>>
>> Error: cannot implicitly convert expression -cast(int)b of
>> type int to
>> byte
> [...]
>
> Honestly, this just makes narrow int types basically useless
> when it comes to any arithmetic at all.
>
In fact you really shouldn’t do arithmetic on narrow integers,
especially as loop counters.
It usually results in suboptimal machine code on optimizing
compilers.
That leaves arrays of bytes and array-wise operations though,
SIMD by definition can operate on a pack of e.g. byte-sized
integers.
Bottom line is to use narrow integers only as a way to pack data
and for SIMD operations in arrays.
>
>
> T
More information about the Digitalmars-d
mailing list