Phobos examples and auto

Kagamin spam at here.lot
Mon Nov 7 05:09:25 PST 2011


Steve Teale Wrote:

> 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.

All you need to know is that it's a time, and you don't need to know anything else. The design makes sure the type supports idiomatic operations, and the type system makes sure the operations are ok. The docs also demonstrate how easy it is to write D: you don't need to know the type name and everything still works.


More information about the Digitalmars-d mailing list