Will macros work with expressions?
Xinok
xnknet at gmail.com
Sun Sep 2 22:01:01 PDT 2007
I agree that macro expressions should be allowed. However, I think a
better syntax would be:
macro foo(e) = e + 3;
Bill Baxter wrote:
> A question about the upcoming macros:
> Will they work for expressions as well as statements?
>
> The examples in WalterAndrei.pdf all show complete statements,
> like
> macro foo(e) { e=3; }
>
> But will it be possible to have:
> macro foo(e) { e+3 }
>
> I hope expressions will be allowed. Not for things like e+3 but for
> making local shortcuts where aliases don't cut it:
>
> macro call_func( arg ) {
> $this.some_member.a_really_long_named_template_member(arg);
> }
> ...
> writefln(call_func(1));
> writefln(call_func("hi"));
>
> And I'm sure there'd be any number of other uses for expression macros.
>
> --bb
More information about the Digitalmars-d
mailing list