mixin macros -- so tantalizing
Daniel Keep
daniel.keep.lists at gmail.com
Fri Sep 7 19:08:25 PDT 2007
Don Clugston wrote:
> With the q{ } token strings we can now do string mixins and get syntax
> highlighting back. It's ugly, though:
>
> mixin(foo(q{a+b*c}));
>
> If we just had something which behaved as
>
> #define func(X) mixin(foo(q{X}))
>
> for example, something like:
>
> mixin alias foo func;
>
> which would declare func as a 'mixin alias' of foo.
>
> (of course, there's the 'macro' keyword as well; 'abstract' is also
> interesting).
> allowing us to write:
>
> func(a+b*c);
>
> which would be instantly applicable. Almost all of the ugliness would
> disappear from my BLADE code, for example.
> By contrast, I still haven't seen any use cases for the macros as
> described in the conference presentation!
I was under the impression that *sound goes batsh!t, machine crashes;
had to reboot, now where was I?* we'd be able to do this:
macro func(e) { mixin(foo(e.stringof)); }
func(a+b*c);
I agree that your method is cleaner, however. That said, you could
probably write a macro that took your ctfe function and turned it into a
macro of itself (oh dear; I'm rather getting ahead of myself, it seems :P).
-- Daniel
More information about the Digitalmars-d
mailing list