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

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 21 12:09:39 PST 2014


On Fri, 21 Nov 2014 11:52:29 -0800
Walter Bright via Digitalmars-d <digitalmars-d at puremagic.com> wrote:

> So 'auto' has different type rules for expressions than anywhere else in D?
> 
> Consider:
> 
>      void foo(T)(T a) { ... }
> 
>      if (x - 1) foo(x - 1);
>      if (auto a = x - 1) foo(a);
> 
> and now foo() is instantiated with a different type?
> 
> I'm afraid I can't sell that to anyone :-(
the whole thing of `auto` is to let compiler decide. i won't be
surprised if `a` becomes 80-bit real or bigint here -- that's up to
compiler to decide which type will be able to hold the whole range.
`auto` for me means "i don't care what type you'll choose, just do it
for me and don't lose any bits." this can be some kind of structure
with overloaded operators, for example.
-------------- 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/dc764367/attachment.sig>


More information about the Digitalmars-d mailing list