auto: useful, annoying or bad practice?

I love Ice Cream IloveIcecream. at icecreamsandwhich.com
Sun May 20 14:33:16 UTC 2018


On Sunday, 20 May 2018 at 02:34:38 UTC, Neia Neutuladh wrote:
> The return type for range-oriented functions in std.algorithm 
> is usually not terribly useful.

So the first question that comes to my mind are what are the 
'rules' of the output. Which is really what typing is. It's a 
series of rules. Your object is allowed to call these 
methods/properties. It is 'this' size. Languages have generic 
returns. D is not the only language with a concept of returning a 
'compiler determined type'. But the rules are always baked into 
the API. If it's not, it's a design failure and more thought 
should be put into it.

The only place I wouldn't be so strict with auto returns is in 
private methods. However, I still might tell someone to think 
about what they are trying to return there. It's not an 
unimportant piece of the API.




More information about the Digitalmars-d mailing list