LLVM Coding Standards

Nick Sabalausky a at a.a
Mon Apr 11 17:34:01 PDT 2011


"Andrei Alexandrescu" <SeeWebsiteForEmail at erdani.org> wrote in message 
news:invnce$2mfr$4 at digitalmars.com...
> On 4/11/11 2:58 PM, spir wrote:
>> [slightly OT]
>>
>> Hello,
>>
>> I'm reading (just for interest) the LLVM Coding Standards at
>> http://llvm.org/docs/CodingStandards.html. Find them very interesting
>> because their purposes are clearly explained. Below sample.
>>
>> Denis
>>
>> === sample ===================================
>> Use Early Exits and continue to Simplify Code
>
> Heh heh heh. This is bound to annoy many a dinosaur. And they even didn't 
> need to pull the exceptions argument!
>

That's something I've come full circle on. I stared out on the old 
interactive BASICs (the ones with line numbers and gratuitous GOTO). So I 
didn't originally have a problem with early exits and continue even after I 
had moved to C/C++ (and started agreeing, from direct experience, with "goto 
is evil" - which I still agree with). Then in the "OO-is-your-God" age of 
the late 90's and early 2000's I found some reasonable sounding arguments 
for avoiding early exits and continue and got very much into the habit of 
avoiding them.

The last few years though, I've been finding that I *never* have any trouble 
grokking code due to early exits or continue (unless the code is already 
convoluted anyway). And I've also realized I find code that makes 
intelligent use of it to be much *easier* to understand and reason about 
since it takes the otherwise-distracting special cases and just shoves them 
out of the way so the rest of the code can focus on the real core of the 
task. Plus, Andrei is right: Reducing the number of nested scopes makes a 
big improvement in readability.

I've often been considered a dinosaur, and probably for good reason. But 
consider this to be one early-exit-and-continue-loving dino. :)





More information about the Digitalmars-d mailing list