[phobos] Initial Phobos style guide proposal
Andrei Alexandrescu
andrei at erdani.com
Thu Mar 31 07:31:32 PDT 2011
On 03/31/2011 07:46 AM, spir wrote:
> On 03/31/2011 05:00 AM, Jonathan M Davis wrote:
>> General Coding Guidelines
>> -------------------------
>> - Prefer anonymous temporaries to named values within reason.
>
> Is this really wished? It's often helpful to readability (provided the
> name is clear).
> It also helps making shorter lines without sacrificing any other good
> point (eg by giving a temp name to a complicated function argument
> expression).
"Within reason" is a key point. I'm just seeing too much code like:
auto widgets = widgets.count();
return widgets > 1;
> To be complete: Use aliases when they provide conceptual information, or
> otherwise clarify the code:
> alias float[3] Position;
> alias Node* Link;
> alias double Time;
> alias ElementType!T Element;
Most if not all of these are common beginner mistakes, particularly if
defined at module level. Please avoid.
Andrei
More information about the phobos
mailing list