Am 23.09.2015 um 16:33 schrieb Nick Sabalausky:

void main()
     int somevar = 42;
     mixin interp;
     iwriteln!("This is ${somevar}.");

     int another = 17;
     iwriteln!("This won't work, using ${another}.");

Seems like it would be too awkward and confusing to be worthwhile. :(

True, it's still far from being good. There is another possible syntax variation:

  mixin template iwriteln(string str, int line = __LINE__)
    auto __dummy_/*~line*/ = () {
      import std.stdio;
      // pretend to parse the input string
      write("Result: ");
      return true;
    } ();

  void main()
    int result = 42;
    mixin iwriteln!"Result: #{result}";

Works only for top-level calls, but has less visual noise, so maybe it makes sense to include that as a convenience function.

Reply via email to