On Friday, 29 April 2022 at 16:10:52 UTC, Salih Dincer wrote:
On Friday, 29 April 2022 at 12:57:15 UTC, Steven Schveighoffer wrote:
[...]

I see, think it can be done with mixin:
```d
template prn(alias args)
{
  string prn()
  {
    string result = "write(";
    foreach(s; args.split("|"))
    {
      result ~= format("%s,", s);
    }
    return result ~ ");";
  }
}

void main()
{
  int data = 456;
  char enter = '\n';

  mixin(prn!q{
    enter| 123 | " str " |  data |

    enter|    __TIME__   | enter }
  );

  mixin(
    prn!q{"This value of " |41| " is prime."}
  );
}
```

If there was some convenience on the compiler side, we could integrate it into D.

SDB@79

There's already an implementation of `mixin` string interpolation in https://github.com/Abscissa/scriptlike
  • T... args! Salih Dincer via Digitalmars-d-learn
    • Re: T... args! Adam Ruppe via Digitalmars-d-learn
      • Re: T... args! Salih Dincer via Digitalmars-d-learn
        • Re: T... args! Petar via Digitalmars-d-learn
        • Re: T... args! Steven Schveighoffer via Digitalmars-d-learn
          • Re: T... arg... Salih Dincer via Digitalmars-d-learn
            • Re: T..... Steven Schveighoffer via Digitalmars-d-learn
              • Re:... Tejas via Digitalmars-d-learn
                • ... Dennis via Digitalmars-d-learn
              • Re:... Salih Dincer via Digitalmars-d-learn
                • ... Tejas via Digitalmars-d-learn
                • ... Salih Dincer via Digitalmars-d-learn

Reply via email to