Fixing spurious "statement is not reachable" in template code

tsbockman via Digitalmars-d digitalmars-d at puremagic.com
Tue Oct 27 14:29:24 PDT 2015


On Tuesday, 27 October 2015 at 21:14:26 UTC, Timon Gehr wrote:
> On 10/27/2015 09:18 PM, tsbockman wrote:
>> I don't think any dead code is being generated,
>
> This seems to be a misunderstanding. I mean generated using 
> mixins or template instantiation. Sure, it will usually be 
> removed, but why generate and semantically analyze it in the 
> first place.

Forcing me to add `static if`s with redundant and potentially 
complex predicates just to make my code do the exact same thing 
it would have done anyway is a violation of "Don't Repeat 
Yourself", with all of the usual consequences:

* The more places the same logic is expressed, the more chances I 
have to get it wrong and cause a bug.

* Even if I get it right the first time, a redundant predicate 
could get out of sync with the rest of the code later, causing a 
bug.

* It's a waste of my time, which is more valuable than my 
computer's time.

* It clutters up the code with statements which add little 
(useful) information.



More information about the Digitalmars-d mailing list