Sugar around string mixins (was: Why not move cast to the standard library?)
Sergey Gromov
snake.scaly at gmail.com
Sat Oct 3 18:22:01 PDT 2009
Fri, 25 Sep 2009 15:35:11 -0400, Adam D. Ruppe wrote:
> ====
> macro max(int a, int b) {
> return a ~ " > " ~ b ~ " ? " ~ a ~ " : " ~ b;
> }
>
> void main() {
> auto num1 = 10;
> auto num2 = 20;
>
> auto result = max(num1, num2);
> }
> ====
While I like and support the idea, I think that hijacking the "macro"
keyword now will make it very hard to re-design later. It would be much
better to reuse the "mixin" keyword for this since it's exactly what's
happening: defining a function for mixing in:
mixin max(int a, int b) {...}
It could be problematic from the grammar perspective though.
More information about the Digitalmars-d
mailing list