any tool to at least partially convert C++ to D (htod for source

Ellery Newcomer ellery-newcomer at utulsa.edu
Wed Mar 10 16:08:44 PST 2010


On 03/10/2010 01:10 PM, Walter Bright wrote:
> Ellery Newcomer wrote:
>> Maybe do a bit of analysis that can tell whether any static ctors in a
>> module use symbols from any other module and use that to determine
>> module dependencies?
>
> This is a transitive thing.

Hmm. That would make things obnoxious.

Furthermore, if you do anything nontrivial,
> you'll be referencing other module symbols. And finally, if you add some
> debugging code like a print statement, suddenly your code will no longer
> run.

Your code never ran in the first place otherwise. Or it did until you 
added some static constructors to initialize some field or other.


Just in case I didn't state my suggestion clearly (I think I did)

As I understand it, when a static constructor is found in a module A, 
then every imported module B must have its static constructor run prior 
to A's. So say you represent that as a flag associated with import B, or 
a directed edge in a graph, or whatever. If A has no static constructors 
then it doesn't participate in the ordering.

My suggestion is that when a symbol from import B is found in A's static 
constructor then B must be ordered before A, but otherwise not. I guess 
transitivity would require you to check the declaration of each local 
symbol that gets called in A's static constructor, or in general, 
everything in A. Come to think of it, that kind of information might be 
useful in the context of IDEs and 'find all usages of this symbol'. I 
might do this..

It wouldn't fix everything, but it would prune the number of 
dependencies that get castigated unjustly.

Don't think it's worthwhile? Maybe it isn't.



More information about the Digitalmars-d mailing list