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

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 21 12:35:31 PST 2014


On 11/21/2014 12:09 PM, ketmar via Digitalmars-d wrote:
> 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.
>

'auto' doesn't mean "break my code if I refactor out expressions into temporaries".


More information about the Digitalmars-d mailing list