Proposal: new variable definition operator

jovo jovo at at.home
Sat Apr 21 05:29:11 PDT 2007


Daniel Keep Wrote:
> 
> Just want to nitpick one thing: you seem to think that "auto" is the
> type inference keyword.  It isn't.  In D, a declaration is made up of
> four parts: the storage class, the type, the identifier and the initialiser.
> 
> Obviously the identifier always needs to be there.  If omitted, the
> initialiser is just type.init.
> 
> Storage class and type are the interesting ones.  In C, you could always
> omit the storage class if it was just a regular variable, but always had
> to specify the type.  D allows you to omit the type if and only if you
> specify the storage class.  Guess what the default storage class is?
> 
> auto.
> 
> Type inference in D isn't "type inference triggered by keyword", it's
> "type inference by omission."  "auto" is only required so that the D
> grammar can tell it's supposed to be an declaration.
> 

What is a meaning of auto as storage class specifier in D? 
In C it signifyes an automatic variable (hence auto) with clear
definition.

C++ faces similar problem introducing type inference via auto.
They will clear auto from list of storage class specifiers.
Just reusing old keyword with new meaning.

jovo




More information about the Digitalmars-d mailing list