What are AST Macros?
Ellery Newcomer
ellery-newcomer at utulsa.edu
Mon Jul 12 06:33:34 PDT 2010
On 07/12/2010 07:30 AM, Steven Schveighoffer wrote:
> On Mon, 12 Jul 2010 08:12:31 -0400, bearophile
> <bearophileHUGS at lycos.com> wrote:
>
>> Steven Schveighoffer:
>>> If people agree that AST macros are superseded by mixins,
>>
>> String mixins are a hack, just a bit better than C preprocessor
>> (because they are scoped), they are not a replacement of clean macros.
>
> Interesting statement, can you back it up? :) What can you do with a
> macro that you can't do with a mixin?
>
> -Steve
I think the big thing about macros is you don't have to worry about
lexing and parsing.
if <A> is of the form (Assignable, Assignable, ... ),
and <B> of the form (AssignExp, AssignExp, ... )
how do you readily rewrite
mixin("<A> = <B>;");
to
(<A>[0] = <B>[0], <A>[1] = <B>[1], ... )
without a metric shit ton of library support?
With the most bare bones of AST macros (maybe a ctfe function that gets
passed a AST* and returns a AST* or something equivalent), it's pretty
trivial. And you don't need to wrap it in a string literal.
More information about the Digitalmars-d
mailing list