Compile time code generation

boolangery eliott.dumeix at gmail.com
Fri Nov 16 17:10:29 UTC 2018


Hi,

Is something like this is doable ?

-------------------------------------------------------------------
// all compile time
MapperGen.Create!(A, B)
     .Map!("p1", "p2")
     .Map!("myprop", "otherprop")
     .Gen();

// The code above must generate something like
//
// class Mapper {
//     B map(A value) {
//         B ret = new B();
//         ret.p1 = value.p2;
//         ret.myprop = p2.otherprop;
//         return ret;
//     }
// }

// runtime use
auto b = new Mapper().map(new A());
-------------------------------------------------------------------

I can't figure out how to concatenate string at runtime and the 
mixin the resulting string?.


Thanks in advance !


More information about the Digitalmars-d-learn mailing list