On 03/30/16 16:20, Meta via Digitalmars-d wrote:
> On Wednesday, 30 March 2016 at 12:57:56 UTC, Mathias Lang wrote:
>> 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.

And making an inferred return type imply attribute inference was a serious
design mistake (there is no such thing as an 'auto' type in D).
Overloading ret-type inference like that, w/o any way to opt-out, means that
ret-type inference became impossible in some situations, at least w/o ugly
hacks to fool the compiler. Keep in mind that we're talking about a
language that lacks a way to name certain classes of symbols, which makes
inference unavoidable...


> Note that giving your function an `auto` return type is the same as making it 
> template function with no template args.

No, it's not. A template is a template, and a function with an inferred
return type is still a function (eg you can instantiate the former and
you can take the address of the latter).

artur

Reply via email to