Template problem - if arg[0]==something; call arg[1];

wobbles via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 27 15:35:54 PDT 2015


I have some code that I'd really like to template-ize.

Currently, I've the same construct all over my code, repeated(yet 
slightly different) about 15 times.
Too much for me, and I'd like to make it into a template.

This is a sample of my current code:
http://dpaste.dzfl.pl/76814846898e

I essentially want to change the
string helper(){
<snip>
     foreach(child; toSpawn.children){
         switch(child.name){
		case "NameOfArg1":
		    str ~= FunctionToCall1;
		    break;
		case "NameOfArg2":
		    str ~= FunctionToCall2;
		    break;
<snip>
}
function to something like:

handleParseTreeHelper!( string NameOfArg1, delegate 
FunctionToCall1,
                         string NameOfArg2, delegate 
FunctionToCall2 );

Any idears?


More information about the Digitalmars-d-learn mailing list