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

Timothee Cour thelastmammoth at gmail.com
Tue Jun 18 10:28:01 PDT 2013


On Tue, Jun 18, 2013 at 6:01 AM, Steven Schveighoffer
<schveiguy at yahoo.com>wrote:

> On Mon, 17 Jun 2013 21:19:57 -0400, Timothee Cour <
> thelastmammoth at gmail.com> wrote:
>
>  I understand your point, however I argued above that we should run a test
>> at compile time to detect cycles. It won't catch all cycles (because of
>> certain di files), but it will catch most of them (at least all of the
>> ones
>> not involving di files). This would be especially handy for people using
>> rdmd.
>> At runtime, we will also run the test to catch all cases.
>>
>
> rdmd could, as an extra step, generate a program that simply exits with 0,
> to check all cycles.  Then run that as part of compilation step.
>
> There isn't a whole lot of difference between checking at compile time and
> checking at runtime before main starts.
>
>
there is: when the binary is created but meant to be run at a later time.
Eg: building a system that requires a set of binaries to be created.

An acceptable solution would be to do the test upon calling rdmd (it should
work with --build-only flag).

Furthermore, I think this could be made to work with dmd itself (even with
di files) by having a data in the object files indicating the module
dependencies, so that dmd will have all the info to do the test at CT. Eg:
dmd -c a.d -Hfa.di
dmd main.d a.di -ofmain
=> should be able to detect cycles.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20130618/484b6963/attachment.html>


More information about the Digitalmars-d-learn mailing list