March 19, 2007 Macro syntax limitations? | ||||
---|---|---|---|---|
| ||||
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
and
StaticClass Foo
{
void bar(){}
}
that would be a macro that creates a completely static class by marking a fields and methods static.
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 :)
|
March 20, 2007 Re: Macro syntax limitations? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johan Granberg | 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 :) |
Copyright © 1999-2021 by the D Language Foundation