can we detect at compile time module ctor/dtor cycles ?

Timothee Cour thelastmammoth at gmail.com
Sun Jun 9 20:15:42 PDT 2013


On Fri, Jun 7, 2013 at 11:41 PM, Jonathan M Davis <jmdavisProg at gmx.com>wrote:

> On Friday, June 07, 2013 23:23:25 Timothee Cour wrote:
> > Why can't we detect at compile time module ctor/dtor cycles (instead of
> > runtime) ?
>
> At minimum, separate compilation stops it. A .di file isn't likely to have
> them
> even if its corresponding .d file did.


automatically generated di files (eg -Hffilename) *do* generate static
this();
All we need is to run an extra test at compile time to test for this. The
might accept invalid code (as is already the case, delaying error to
runtime; ie false positive), but will have no false negatives (if a cycle
is detected at CT, it can safely reject the code as runtime test will also
find the cycle). I'd further argue that in large majority of cases there
should be no false positives, due to auto generated di files generating
static this();

IIRC, there were other reasons as well, but I don't remember them at the
> moment.
>

so I guess it would only depend on those 'other reasons'. Does anyone have
an idea what those could be?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20130609/2e8283cf/attachment.html>


More information about the Digitalmars-d-learn mailing list