auto: useful, annoying or bad practice?

Mark smarksc at gmail.com
Fri May 11 16:57:05 UTC 2018


On Wednesday, 9 May 2018 at 15:06:55 UTC, Jonathan M Davis wrote:
> Ultimately, the key is that the user of the function needs to 
> be able to know how to use the return type. In some cases, that 
> means returning a specific type, whereas in others, it means 
> using auto and being clear in the documentation about what kind 
> of API the return type has. As long as the API is clear, then 
> auto can be fantastic, but if the documentation is poorly 
> written (or non-existant), then it can be a serious problem.
>
> - Jonathan M Davis

He also needs to know what requirements the parameters of the 
function should satisfy. We have template constraints for that, 
even though that could also have been "implemented" through 
documentation.


More information about the Digitalmars-d mailing list