On Thu, 09 May 2013 19:51:47 -0400, Manu <turkey...@gmail.com> wrote:
On 10 May 2013 08:50, Timon Gehr <timon.g...@gmx.ch> wrote:
auto was carried over from C and originally stands for local lifetime.
It
does _not_ mean "apply type deduction here".
Eh? 'local lifetime' doesn't sound like it has anything to do with 'apply
type deduction here' to me; which is what D does.
auto does not imply type deduction, it is a storage class. D is able to
imply type deduction when it knows you are declaring a variable (hence the
storage class) and you omit the type. auto actually means 'local' in C.
D carries on that tradition, but adds the ability to define the type based
on the assignment.
These all work:
auto x = 1;
static x = 1;
const x = 1;
If the ref storage class could be used in a function/struct, this would
work too:
ref x = foo(); // assuming foo returns by ref
Is this an argument to continue that trend?
That said, I don't find this to be particularly true. Most things make
reasonable sense.
I think there is no good reason to use auto ref, except that it's already
in the book. Any storage class would be fine, and auto ref is going to be
super-confusing because it's used elsewhere. Just my opinion.
-Steve