<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<HTML>
<HEAD></HEAD>
<BODY style="font-family:'DejaVu Sans Mono'; font-size:12px"><div>On Sun, 11 Jul 2010 21:55:30 +0200, Philippe Sigaud <philippe.sigaud@gmail.com> wrote:<br><br><blockquote style="margin: 0 0 0.80ex; border-left: #0000FF 2px solid; padding-left: 1ex"><div class="gmail_quote">On Sun, Jul 11, 2010 at 18:58, Rory McGuire <span dir="ltr"><<a href="mailto:rmcguire@neonova.co.za">rmcguire@neonova.co.za</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div class="h5">On Sun, 11 Jul 2010 15:29:36 +0200, Michel Fortin <<a href="mailto:michel.fortin@michelf.com" target="_blank">michel.fortin@michelf.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
int num = 1;<br>
string result = substitute!"Number: $num";<br>
assert(result == "Number: 1");<br>
<br>
</blockquote>
<br></div></div>
someone already made something like that, I forget where it was. Its old now.<br>
</blockquote></div><br>Doesn't Format (in std.metastrings) cover part of this?<br><br>string result = Format!("Numbers: %s", to!string(num));<br><br>I remember finding it cumbersome to use. For one, it could easily take any type for argument, and call to!string on them internally. Why bothering me with this?<br>
But maybe I wasn't using it the right way.<br><br>Hmm, I think what I'd like is some numbered substituting scheme:<br><br>string result = Substitute!("static if (is (typeof(%1) t == %2!U, U)) {<br> alias U Result;<br>
else<br> alias typeof(%1) Result;", <br> a,b);<br><br><br>I agree with Rory than someone already did something similar. But I guess now it can be done with CTFE on strings. A CT replace.<br>
<br><br>Philippe<br><br>
</blockquote><br><br>I think I found what I was thinking of (not sure its the same one):<br></div><div>http://www.digitalmars.com/d/archives/digitalmars/D/PHP-style_embedded_variables_print_statements_54053.html</div><div><br></div><div>-Rory</div></BODY></HTML>