On Tuesday, March 08, 2016 14:56:06 Antonio Corbi via Digitalmars-d-learn wrote: > 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.
The return type is optional so long as one of the keywords that indicates that it's a variable or a function is there, so you can choose to put it or not. In most cases, I think that folks put the return type on functions or use auto, but it's up to you. Where it usually comes up is enums and variable declarations. - Jonathan M Davis