What are AST Macros?
Philippe Sigaud
philippe.sigaud at gmail.com
Sun Jul 11 12:55:30 PDT 2010
On Sun, Jul 11, 2010 at 18:58, Rory McGuire <rmcguire at neonova.co.za> wrote:
> On Sun, 11 Jul 2010 15:29:36 +0200, Michel Fortin <
> michel.fortin at michelf.com> wrote:
>
>>
>> int num = 1;
>> string result = substitute!"Number: $num";
>> assert(result == "Number: 1");
>>
>>
> someone already made something like that, I forget where it was. Its old
> now.
>
Doesn't Format (in std.metastrings) cover part of this?
string result = Format!("Numbers: %s", to!string(num));
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?
But maybe I wasn't using it the right way.
Hmm, I think what I'd like is some numbered substituting scheme:
string result = Substitute!("static if (is (typeof(%1) t == %2!U, U)) {
alias U Result;
else
alias typeof(%1)
Result;",
a,b);
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.
Philippe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100711/a9d46266/attachment.html>
More information about the Digitalmars-d
mailing list