Scriptlike v0.9.4 - Perl-like interpolated strings, full examples and more.
Jacob Carlborg via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Tue Sep 22 23:21:00 PDT 2015
On 2015-09-22 22:18, Nick Sabalausky wrote:
> =====================
> String Interpolation:
> =====================
> https://github.com/Abscissa/scriptlike#string-interpolation
>
> AFAICT, a string mixin is necessary to accomplish this in D, but
> otherwise it works much like other languages:
>
> --------------------------------------------
> // Output: The number 21 doubled is 42!
> int num = 21;
> writeln(
> mixin(interp!"The number ${num} doubled is ${num * 2}!")
> );
> --------------------------------------------
>
> The interpolated sections are handled via std.conv.text(), so they
> accept any type.
>
> Bikeshedding requested! I'm not 100% sold on the name "interp" for this
> long-term. Suggestions welcome.
Different bikeshedding: I would prefer to make the curly braces optional
if it only contains a symbol.
--
/Jacob Carlborg
More information about the Digitalmars-d-announce
mailing list