On 2013-09-10 10:49, Joseph Rushton Wakeling wrote:
Can you explain a bit more about how that works?
The "object" module, part of druntime defines a template with the name
"RTInfo". That template will be instantiated with each user defined type.
Currently RTInfo doesn't do anything:
template RTInfo(T)
{
enum RTInfo = cast(void*)0x12345678;
}
https://github.com/D-Programming-Language/druntime/blob/master/src/object.di#L575
If you replace that template with something like:
template RTInfo(T)
{
enum RTInfo = verifyDeclarations!(T);
}
verifyDeclarations would look something like this, in pseudo code:
void* verifyDeclarations (T) ()
{
static if (is(T == class))
{
foreach (member ; methods!(T))
{
static if (!hasDefinition!(member))
static assert (false, "The member '"
fullyQualifiedName!(T) ~ "." ~ member.stringof ~ "' doesn't have a
definition");
}
}
return null;
}
As long as it can provide a guarantee that everything declared has a
definition, and everything defined has a declaration -- and that they
match! -- then I think this is probably the solution required.
What I mean is -- it needs to ensure that the issue identified in a
couple of my earlier posts will be flagged and prevented:
http://forum.dlang.org/post/mailman.1104.1378795749.1719.digitalmar...@puremagic.com
However, I'm suspicious of anything that would require the programmer to
be "virtuous" and manually ensure that those checks take place, rather
than the checks simply being a natural part of the compilation process.
The idea is then you build a tool that "compiles" all your files which
uses druntime with the above implementation of RTInfo.
--
/Jacob Carlborg