digitalmars.D - Macro syntax limitations?
- Johan Granberg (19/27) Mar 19 2007 Seeing this syntax i think it is fair to that macros can be made to look
- Walter Bright (3/38) Mar 19 2007 Probably not.
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 :)
Mar 19 2007
Johan Granberg wrote:Broken out from another thread Walter Bright wrote:Probably wouldn't work unless statement; had { } around it.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 ifand 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 :)
Mar 19 2007