Carmack about static analysis

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Dec 25 16:40:45 PST 2011


On 12/25/11 5:13 PM, Adam D. Ruppe wrote:
> On Sunday, 25 December 2011 at 04:44:57 UTC, Andrei Alexandrescu wrote:
>> I see every letter beyond this as a liability:
>
> Yeah, though like Jacob said, the implementation doesn't
> matter as much as the idea of giving it a name.
>
> But, if you're curious about why I wrote it long form, it's
> just a quirk I sometimes do; if I read something out loud
> differently than how I wrote it, I'll sometimes rewrite it.
> Here, I dictated it to myself as "if it's divisible by two,
> return false (not odd), otherwise, return true (is odd)", and
> decided to write it almost exactly like that.

I understand. Personally, I am unable to bring myself to fathom why 
writing this has any advantage:

if (condition)
     return true; // or false
else
     return false; // or true, respectively

as much as I'm unable to fathom why writing this has any advantage:

if (expression == true) ...

or

if (expression == false) ...

I might be biased, but I ask for it to be corrected if I see it during a 
code review at work, and if someones writes such during an interview, it 
doesn't gain them any points.

> Usually, these little things are meaningless once compiled,
> but check this out:
[snip]

I'd say that's a good enhancement request for the backend.


Andrei


More information about the Digitalmars-d mailing list