On Friday, 5 June 2015 at 12:33:35 UTC, ketmar wrote:
On Fri, 05 Jun 2015 11:53:29 +0000, Marc Schütz wrote:
My understanding is that `auto` is just C legacy, and
originally had the
same meaning as in C. But apparently the language has moved
away from
that over time.
i agree, i think it was a keyword used 'cause it was already
used in C.
but it's meaning is completely redefined in D.
AFAIK auto is a stotage class (like in C). It is the no-op
storage and therefore does not not change the stotage or type
etc. But in a statement it definitely marks as a declaration
because only those can contain storage classes. In D any
declaration can omit the type so let it be inferred. That's why
this also works:
const x = 10;
static y = 20;
enum z = 30;
Auto is only needed to unambigiously mark a statement as
declaration when the lack of type would make it look like an
ExpressionStatement. But still
auto int x = 10;
should work. It's just consistent.