On Wednesday, 6 November 2013 at 22:33:36 UTC, H. S. Teoh wrote:
Challenge accepted. ;-) Here is an adaptation of Dmitri's code that
doesn't require you to explicitly pass in variables:
...
Is that acceptable to you? :)


Good stuff.

Of course, the above code is just a proof-of-concept; it doesn't handle integer or other types of variables, and it currently only escapes '"', (it should be extended to also escape '\', etc.). But all of these would be easily addressed by a proper implementation using std.conv and by handling metacharacters properly. The point is that you *can* do string
interpolation in D without needing language-level support.


Absolutely - I was not under the impression it needed to be provided by the language proper. But a standard library would be nice. I look forward to seeing/using Timothy's version when it is ready. Lack of interpolation is one reason I went with Dart for my code generation tasks.

Reply via email to