Macros: a visual aid.

Bill Baxter dnewsgroup at billbaxter.com
Sun Jul 8 15:18:17 PDT 2007


janderson wrote:
> 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

I like 'em to look like normal functions too.

But I assume taking the address of a macro will fail.  So "fptr = &foo;" 
will work on a function but not a macro.
There are probably other way in which they will differ, but that seems 
to be the biggie to me.
--bb



More information about the Digitalmars-d mailing list