'int' is enough for 'length' to migrate code from x86 to x64

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 21 10:08:13 PST 2014


On Fri, 21 Nov 2014 09:08:54 -0800
"H. S. Teoh via Digitalmars-d" <digitalmars-d at puremagic.com> 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20141121/95f9db59/attachment.sig>


More information about the Digitalmars-d mailing list