Attribute inference for auto functions?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Apr 17 08:12:55 PDT 2013


On 4/17/13 3:58 AM, deadalnix wrote:
> Note that this is consistent with many choice D made.
>
> auto is a storage class. storage class usually stick to the function,
> not the return type :
> const Foo bar(); // Error as const qualify bar and not Foo.
>
> auto is about type inference. Attribute is part of the function type as
> much as it return type, and so it is expected that auto applied to a
> function infer its attributes and its return type.
>
> The problem you are talking about is very real, but much broader than
> this auto thing. The problem is that you have no control on what the
> storage classes bind on.
>
> Examples :
> extern(C) void function() foo; // does extern binds to foo, foo's type
> or both ?
> pure function() function() bar; // is bar a pure function ? is bar()
> pure ? Noth ? How to choose ?
>
> Back to the subject, if auto bind to the function it must infers
> attributes, if it binds to the return type, it mustn't. And right now,
> storage class bind to the function.

I think this is a solid argument. You may want to paste it in the github 
discussion for reference.

Andrei


More information about the Digitalmars-d mailing list