digitalmars.D - aliasing main
- monkyyy (27/27) Jun 19 recently I've been looking into creating dsl's via templates
recently I've been looking into creating dsl's via templates ... its not going well however what does just werk^tm is aliasing main ```d struct dsl{ string exe(string s){ return s; }} template repl(alias T){ pragma(mangle, "main") int repl(){ import std; T machine; foreach(in_;stdin.byLineCopy){ if(in_=="quit")return 0; if(in_=="vomit"){ machine.writeln; } else { machine.exe(in_).writeln; }} assert(0); }} alias main=repl!dsl; ``` I think some stuff is broken like exceptions, but maybe some common patterns should be extracted out to make even smaller programs
Jun 19