Calling functions using mixins

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 1 14:59:30 PDT 2015


On 05/01/2015 02:41 PM, Dennis Ritchie wrote:

 >      immutable string[] s = [ "foo", "bar" ];
 >
 >      writeln(mixin(`format("%(%s, %)", s)`));;

If you are trying to call those functions, remove the double quotes by 
%-(, and use %| to specify what is a delimiter. To call, each needs a 
semicolon:

     mixin(format("%-(%s();%| %)", s));

If you wanted to print the results of calling those functions, then, 
yes, use a comma. Also, I think you need to put "writeln" inside as well:

     mixin(format("writeln(%-(%s(), %));", s));

Ali



More information about the Digitalmars-d-learn mailing list