What are AST Macros?
Rory McGuire
rmcguire at neonova.co.za
Sun Jul 11 13:07:22 PDT 2010
On Sun, 11 Jul 2010 21:55:30 +0200, Philippe Sigaud
<philippe.sigaud at gmail.com> wrote:
> 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
>
I think I found what I was thinking of (not sure its the same one):
http://www.digitalmars.com/d/archives/digitalmars/D/PHP-style_embedded_variables_print_statements_54053.html
-Rory
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100711/ecca36fd/attachment.html>
More information about the Digitalmars-d
mailing list