static property without return type
Peter Alexander
peter.alexander.au at gmail.com
Sat Mar 16 20:39:08 PDT 2013
On Sunday, 17 March 2013 at 01:06:22 UTC, Andrej Mitrovic wrote:
> On 3/17/13, Timon Gehr <timon.gehr at gmx.ch> wrote:
>> No, if the return type is missing, it is deduced.
>
> What are you talking about? You can't write:
>
> foo() { return 0; }
Timon is right here. The reason you cannot write that is because
the parser needs the auto crutch. Basically, the parser just
needs to see at least one "storage class" before the function
identifier. Note that "storage class" here includes things like
pure, which isn't really a storage class (see
http://dlang.org/declaration.html#StorageClass)
Note that you can write:
const foo() { return 0; }
Type is deduced here, but the presence of const means that the
parser doesn't need any other storage class. auto in D actually
just means "I don't want to use any other storage class", the
type deduction is triggered by the lack of return type.
More information about the Digitalmars-d
mailing list