Proposed improvements to the separate compilation model
bearophile
bearophileHUGS at lycos.com
Sat Jul 23 15:39:01 PDT 2011
Andrei:
I am not expert on this, but it doesn't look like esoteric stuff.
> Consider:
Thank you for explaining better, with more examples. This usually helps the discussion.
> Say the team working on A wants to "freeze" a.di without precluding work
> on A.fun().
Currently in D there is no explicit & enforced way to state this desire to the compiler?
> The problem with this setup is that it's extremely fragile, in ways that
> are undetectable during compilation or runtime.
Is it possible to invent ways to make this less fragile?
> For example, just
> swapping a and b in the implementation file makes the program print
> "08.96566e-31344". Similar issues occur if fields or methods are added
> or removed from one file but not the other.
I have suggested some fine-grained hashing. Compute a hash from a class definition, and later quickly compare this value with a value stored elsewhere (like automatically written in the .di file).
> Ultimately the programmers figure there's no way to keep files separate
> without establishing a build mechanism that e.g. generates a.di from
> a.d, compares it against the existing a.di, and complains if the two
> aren't identical.
Comparing .di files looks tricky. DMD generates them deterministically, so in theory it works, but it doesn't sound like a good thing to do.
> They must define
> one class with everything in one place, and there's no way out of that.
I think C# uses partial classes to solve this. It doesn't use header files.
http://msdn.microsoft.com/en-us/library/wa80x488%28v=vs.80%29.aspx
Bye,
bearophile
More information about the Digitalmars-d
mailing list