A code example that shows why I don't like warnings

Adam D. Ruppe destructionator at gmail.com
Fri Oct 18 16:46:36 UTC 2019


On Friday, 18 October 2019 at 16:43:54 UTC, FeepingCreature wrote:
> This does **not** spark joy. But it works.

Yes, I just put in a runtime condition to trick the compiler:

bool isScriptable(attributes...)() {
         bool nonConstConditionForWorkingAroundASpuriousDmdWarning 
= true;
         foreach(attribute; attributes) {
                 static if(is(typeof(attribute) == string)) {
                         static if(attribute == scriptable) {
                                 
if(nonConstConditionForWorkingAroundASpuriousDmdWarning)
                                 return true;
                         }
                 }
         }
         return false;
}


the optimizer can prolly remove that condition anyway but it is 
good enough to silence the warning. still just all the work 
arounds are kinda gross.


More information about the Digitalmars-d mailing list