On Fri, 21 Nov 2014 09:08:54 -0800
"H. S. Teoh via Digitalmars-d" <[email protected]> wrote:

> > >>What about:
> > >>
> > >>      uint x;
> > >>      auto z = x - 1;
> > >>
> > >>?
> > >>
> > >here z must be `long`. and for `ulong` compiler must emit error.
> 
> What if x==uint.max?
nothing bad, long is perfectly able to represent that.

> > Would you agree that that would break a substantial amount of correct
> > D code? -- Andrei
> 
> Yeah I don't think it's a good idea for subtraction to yield a different
> type from its operands. Non-closure of operators (i.e., results are of a
> different type than operands) leads to a lot of frustration because you
> keep ending up with the wrong type, and inevitably people will just
> throw in random casts everywhere just to make things work.
not any subtraction, only that with `auto` vardecl.

Attachment: signature.asc
Description: PGP signature

Reply via email to