We're #1 on Hacker News at the moment!

Steven Schveighoffer schveiguy at gmail.com
Tue Apr 28 18:07:07 UTC 2020


On 4/28/20 1:06 PM, Adam D. Ruppe wrote:
> On Tuesday, 28 April 2020 at 16:50:20 UTC, Laust wrote:
>> The lukewarm response and the type inference argument make me sad.
> 
> Type inference itself isn't bad, but the auto in documentation is 
> something I agree isn't great.
> 
> So I recently wrote this thing:
> http://dpldocs.info/experimental-docs/arsd.mvd.mvd.html
> 
> 
> It originally said:
> 
> auto mvd(alias fn).......
> 
> and then I changed it to:
> 
> CommonReturnOfOverloads!fn mvd(alias fn).......
> 
> 
> just because I wanted the return type to be a little bit clearer. And 
> you can use the helper thing externally too which is sometimes useful.
> 
> But it could just as well have said /// Returns: common type of 
> overloads of the passed function
> 
> sooooo idk, just I kinda see the point and have avoided `auto` for 
> exactly that reason myself sometimes.

Yeah, the whole thread is ignoring that there's actual documentation for 
those functions which says what it returns, and IMO it's more 
descriptive than some long machine-usable multi-page type generation 
thing that nobody will comprehend.

There are certainly cases where auto is overused. I also think, if there 
is a non-template return type, auto could be changed to returning that 
type in the docs.

Like I had to make this change, but it would have been nice if the 
compiler just did it for me: https://github.com/dlang/phobos/pull/7451

-Steve


More information about the Digitalmars-d mailing list