[OT] The Usual Arithmetic Confusions

Walter Bright newshound2 at digitalmars.com
Sat Feb 5 02:43:27 UTC 2022


On 2/4/2022 3:51 PM, Adam Ruppe wrote:
> On Friday, 4 February 2022 at 23:36:11 UTC, Adam Ruppe wrote:
>> I don't think you understand my proposal, which is closer to C's existing 
>> rules than D is now.
> 
> To reiterate:
> 
> C's rule: int promote, DO allow narrowing implicit conversion.
> 
> D's rule: int promote, do NOT allow narrowing implicit conversion unless VRP 
> passes.
> 
> My proposed rule: int promote, do NOT allow narrowing implicit conversion unless 
> VRP passes OR the requested conversion is the same as the largest input type 
> (with literals excluded unless their value is obviously out of range).

We considered that and chose not to go that route, on the grounds that we were 
trying to minimize invisible truncation.

P.S. as a pragmatic programmer, I find very little use for shorts other than 
saving some space in a data structure. Using shorts as temporaries is a code smell.


More information about the Digitalmars-d mailing list