On 5/16/25 12:19 PM, H. S. Teoh wrote:

> Basically, `a + 5` gets promoted to int, and that's why it can't be
> assigned back to `a`.  (Don't ask me why, that's just the way it is and
> Walter has refused and probably will continue to refuse to change it.)

Overloaded functions must also be considered. I doubt there is any code out there that would start behaving unexpectedly with such a change but the following code might be dispatched to another function:

  foo(a + 5);

Related: Template instantiation...

And what if ubyte and int appeared in the same expression:

  int i;
  a + 5 + i;

If the rules were changed, we would still expect the expression to be int I guess. But then, wasn't 5 an int with today's rules? With the proposed change, we would still be following the same rule; roughly: the type of the largest expression...

Such messy rules of programming languages are not easy to clean up and there are natural reasons why they are messy. I agree with Walter that the best action is to follow what other system programming languages do in this case.

Ali

Reply via email to