what would be the idiomatic way to write this D code in nim?

it calls a function by name (provided at runtime), trying all possibilities 
until a match is found.
    
    
    import std.stdio:writeln;
    void fun1(){writeln("ok1");}
    void fun2(){writeln("ok2");}
    
    void callFun(string fun){
      static foreach(funi; ["fun1", "fun2"]){
        if(funi == fun){
          mixin(funi~"();");
          return;
        }
      }
    }
    
    void main(){
      callFun("fun1");
    }
    

Reply via email to