Macros: a visual aid.

janderson askme at me.com
Sun Jul 8 14:15:39 PDT 2007


Chris Nicholson-Sauls wrote:
> While I'm looking forward to 2.0 macros, I've already noted one thing: 
> they look an awful lot like a CTF call.  Given:
> 
> macro Foo () { ... }
> char[] Bar () { ... }
> 
> Foo();
> Bar();
> 
> Can you tell a difference?  No?  Then we're on the same page.  :)
> 
> So I had an idea: why not decorate the macro invocation in some way to 
> make it stand out, such as how template instantiation uses '!()' rather 
> than '()'.  I don't think re-using '!()' would be a good idea at all, so 
> I pondered alternatives and arrived at something that might be familiar 
> to some... the '@' sign.
> 
> macro Foo () { ... }
> char[] Bar () { ... }
> 
> @Foo();
> Bar();
> 
> Now that stands out!  So Walter, please consider some sort of decoration 
> (such as the '@') for macro invocations.  I think it may save some 
> future headaches, /and/ give the parser something to latch on to.
> 
> -- Chris Nicholson-Sauls


I like the fact that they look exactly like normal functions.  It means 
you can change an interface to a function or macro without the user 
knowing.  The only problem here of course is if macros work 
significantly different from their function counter part that it causes 
problems.

-Joel



More information about the Digitalmars-d mailing list