Are there any default dmd optimizations
Jacob Carlborg
doob at me.com
Wed Feb 27 04:28:40 PST 2013
On 2013-02-26 20:53, Walter Bright wrote:
> On 2/25/2013 11:56 PM, foobar wrote:
>> DDoc isn't part of the language but rather part of the compiler,
>> nevertheless it
>> has its downsides. [...]
>> unittest is worse,
[SNIP]
I'm going to use the big "if".
If the D compiler was built properly as a library, preferably in D. We
could build all these features as separate tools (Ddoc, unit test) with
the help of the compiler. These tools would then be included in the D
distribution. Actually, the unit test support doesn't need the compiler
as a library.
The build in unit tests support doesn't give much. It's easily
implemented as a library with a simple tool to drive it. Example:
void unitTest (void delegate () dg);
static this ()
{
unitTest({
assert(true);
});
}
It's then easy to add support for named unit tests:
void unitTest (string name, void delegate () dg);
static this ()
{
unitTest("foo", {
assert(true);
});
}
If we then add some syntax sugar and allow a delegate to be passed after
the parameter list we could have this:
static this ()
{
unitTest("foo") {
assert(true);
}
}
If we then could support having arbitrary code at top level we would
have this:
unitTest("foo") {
assert(true);
}
Which is basically the same syntax as we have now but it's implemented
as a library function. It can easily be extended with other similar
functions doing slightly different things.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list