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 <[email protected]> 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".
