Hello,

Back in C days I used to write code with function pointer to avoid writing branches inside loops,

To avoid this:

for(;;){
  if(opt == 1){ func_1(); }else{func_2()};
}
Or maybe using switch if there were more options...

So I used to do:

if(opt == 1){ fp  = &func_1(); }else{ fp = &func_2()};

for(;;){
 fp();
}


I would like to know if there is a different way of doing that in D during RT execution and dynamic change of function execution before the loops?

Thanks in advance,

Matheus.
  • Doubt Branchless... matheus via Digitalmars-d-learn
    • Re: Doubt B... matheus via Digitalmars-d-learn
    • Re: Doubt B... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: Dou... matheus via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn

Reply via email to