Are there any default dmd optimizations

Jacob Carlborg doob at me.com
Wed Feb 27 02:42:53 PST 2013


On 2013-02-27 00:37, Andrei Alexandrescu wrote:

> Agreed, but it does happen often that a language feature is later
> superseded by a generalization thereof.

In this case it would be two features:

1. Allow to run arbitrary code at top level
2. Allow to pass a delegate to a function after the parameter list

void unittest (void delegate () dg)

unittest {
     assert(true);
}

Would be lowered to:

unittest({
     assert(true);
});

Then we also can easily support named unit tests:

void unittest (string name, void delegate () dg)

unittest("foo") {
     assert(true);
}

Would be lowered to:

unittest("foo", {
     assert(true);
});

I think it would be nice if D could get better at declarative programming.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list