Needed return type in static method? bug or feature?

Antonio Corbi via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Mar 8 06:56:06 PST 2016


On Tuesday, 8 March 2016 at 14:13:17 UTC, Adam D. Ruppe wrote:
> On Tuesday, 8 March 2016 at 13:40:06 UTC, Antonio Corbi wrote:
>> Is it a feature or a bug?
>
> It is allowed because the "auto" keyword doesn't actually 
> required for auto functions (or variables), what you need is 
> any one of the storage classes.
>
> Those include static, auto, const, immutable, even pure.
>
> If any of them are present, the compiler knows you are writing 
> a function or declaring a variable and will infer the type.

Thank's Adam!.

I had figured out something like this but I couldn't find 
anything in the docs 
(http://dlang.org/spec/attribute.html#static), moreover, the 
example there:
----------8><---------------------
class Foo
{
     static int bar() { return 6; }
...
----------8><---------------------

does mention the return type, that's what confused me.



More information about the Digitalmars-d-learn mailing list