October 25, 2019
On 10/25/2019 07:34 AM, Robert M. Münch wrote:

> If the compiler is a 1-pass one I see the problem, otherwise one could
> first get a "total overview" and create the necessary vtbl entries after
> everything is known. Maybe this is not "how a compiler is implemented"
> but the problem sounds solvable for me.

Unfortunately, it's not the compiler but the linker that produces the program (dmd and others conveniently call the linker behind the scenes).

It's common to compile the compilation units e.g. with "dmd -c" and then link them together at the end. C++ has been suffering from the fact that linkers are language agnostic but the linker is a part of the operating system, so this is what we got.

Otherwise, I would agree with you. But even then, what about dynamic libraries? The library was built with 7 instances of a template but I have 8 instances in my program. This is related to the operating system 'loader', which happens to be the sister of the 'linker'. :)

Ali


October 26, 2019
On 2019-10-25 15:20:21 +0000, Ali ‡ehreli said:

> On 10/25/2019 07:34 AM, Robert M. Münch wrote:
> 
>  > If the compiler is a 1-pass one I see the problem, otherwise one could
>  > first get a "total overview" and create the necessary vtbl entries after
>  > everything is known. Maybe this is not "how a compiler is implemented"
>  > but the problem sounds solvable for me.
> 
> Unfortunately, it's not the compiler but the linker that produces the program (dmd and others conveniently call the linker behind the scenes).

Yes, sure...

> It's common to compile the compilation units e.g. with "dmd -c" and then link them together at the end. C++ has been suffering from the fact that linkers are language agnostic but the linker is a part of the operating system, so this is what we got.
> 
> Otherwise, I would agree with you. But even then, what about dynamic libraries? The library was built with 7 instances of a template but I have 8 instances in my program. This is related to the operating system 'loader', which happens to be the sister of the 'linker'. :)

The thing here would be to "instrument" or generate other code if such a case shows up, so be prepared for the case when such a dynamic case shows up. However, I can imagine that at the end one ends with a VM, that provides an eco-system that abstracts all these problems away... but than you are no longer a system language and won't have the common C compatible ABI.

I'll live the with cicumstance and as you showed, there is a solution to the problem.

-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster

1 2
Next ›   Last »