Attribute inference for non-templated functions

Seb via Digitalmars-d digitalmars-d at puremagic.com
Wed Mar 30 08:26:21 PDT 2016


On Wednesday, 30 March 2016 at 12:57:56 UTC, Mathias Lang wrote:
>> My question is whether this is just an open issue (I couldn't 
>> find it) or a design decision?
>
> It's a design decision. You want to be able to fix the exact 
> type of your function, in order to provide headers for them for 
> example (so you can work with libraries for which the source 
> code is not available).
>
> If you want attribute inference, you can either make it a dummy 
> template or, with a recent enough compiler, use `auto` return 
> type.

OK so it makes sense to recommend to always use `auto` for 
non-templated functions in high-level parts of Phobos?
The current guideline recommends to specify the return type for 
better readability in the code and documentation, but I guess the 
latter can be eventually fixed and having automatic attribute 
inference is way more important than the first point?

(given that most of Phobos makes extensive use of templates, this 
shouldn't be a huge issue anyway)


More information about the Digitalmars-d mailing list