Macro syntax limitations?
Walter Bright
newshound at digitalmars.com
Mon Mar 19 17:41:57 PDT 2007
Johan Granberg wrote:
> Broken out from another thread
>
> Walter Bright wrote:
>> There's a way to do this using specialization:
>>
>> macro foo(somevec : somevec+=othervec+somevec, othervec)
>>
>> which will only match for parameters of the form:
>>
>> foo( a += b + a);
>>
>
> Seeing this syntax i think it is fair to that macros can be made to look
> like function calls but will we be able to emulate other constructs to?
> and what are the limitations?
>
> some examples that might be nice to be able to do
>
> unless(condition)
> statement;
>
> statement that could be a block or a single line like in if
Probably wouldn't work unless statement; had { } around it.
> and
>
> StaticClass Foo
> {
> void bar(){}
> }
>
> that would be a macro that creates a completely static class by marking a
> fields and methods static.
Probably not.
> Don't focus to muck on the usefullness of the examples but more if it will
> be possible with D's macros.
>
> ps. The macros look real promissing keep up the good work :)
More information about the Digitalmars-d
mailing list