Please do not use 'auto' return types without thoroughly describing the interface

Neia Neutuladh neia at ikeran.org
Wed Dec 27 18:43:38 UTC 2017


On Wednesday, 27 December 2017 at 16:36:59 UTC, H. S. Teoh wrote:
> The best we can do currently, which unfortunately won't show up 
> in the docs, is to use a static assert to force compilation 
> failure when the return type doesn't match expectations, e.g.:
[...]
> 		static assert(isInputRange!Result);

I'm more concerned about types that are specific to a purpose 
with an interface that is not standard and widely used across a 
lot of D code. Which is why I'm talking about std.regex.Captures 
and not std.algorithm.iteration.MapResult: MapResult is just a 
range implementation, and ranges are a core concept in D today.

And this is about documentation, so a static assert inside the 
implementation doesn't really help.


More information about the Digitalmars-d mailing list