Phobos examples and auto

Marco Leise Marco.Leise at gmx.de
Sat Nov 5 13:41:26 PDT 2011


Am 05.11.2011, 18:42 Uhr, schrieb Steve Teale  
<steve.teale at britseyeview.com>:

> There's a growing tendency in Phobos documentation to use auto.
>
> auto now = Clock.currTime();
>
> Now I can understand that when the RHS is some obscure template, whose
> type might not be immediately obvious, the user should possibly be
> encouraged to RTFM. But if the outcome is deterministic I just have the
> feeling that documentation should provide information rather than hiding
> it.
>
> OK, in Jonathan's example, this is preceded by a sentence that says that
> the result is a SysTime. But the auto made me forget, and wonder what it
> was, rather than reinforcing the preceding sentence.
>
> I realize that this is probably a trivial point, but at the same time, in
> documentation, clarity is wonderful.
>
> Steve

+1

And DDOC, IDEs and other tools should print/know about the inferred type  
of auto and the examples should use the actual type, unless it is for  
example some Range type or obvious from the right hand side of an  
assignment. This is also what I try to do in my own code, because auto  
keeps confusing me and DDT doesn't know how to infer the type yet :p


More information about the Digitalmars-d mailing list