>
> Not sure what you mean by class size fragility.
>>
>
AFAIK, C++ in-memory layouts and sizes are defined by inlining header
meaning, not by deferring to the DLL. This means that C++ new, and
stack-allocated classes inline the size of classes separately into the
caller and the DLL. This is a similar but more pervasive problem than the
FBC. By way of example, I believe the following to be true:

Foo *a = new Foo();   // means...   Foo *a = malloc(sizeof(Foo));
Foo a;  // means ... Foo &a = alloca(sizeof(Foo));

I suppose this is a lesser problem than the FBC, since it can be worked
around by forbidding direct or stack allocation, and always allocating
through factories.

2) C structures in DLLs also have fragility regarding sizing and offset
>> layout. However, the issues are more direct, easier to avoid, and AFAIK
>> there is no current system runtime which avoids them.
>>
>
> Actually, C structures are *much* better than C++ classes, because the
> consequences of adding fields to the shape of the structure are well
> defined and visible to the programmer. Yes, it's possible to have problems,
> but it's also possible to avoid them. In C++, it's not possible to avoid
> them in some cases.
>

This is my feeling as well. I think ABI binary-compatibility issues are not
thought about by many. The intertwined dependencies of subtyping, modular
run-time binding, static field offsets, and JIT are mathematically
inevitable but not intuitively obvious.

A curious data-point on in this brief C++ discussion is Objective-C. AFAIK,
it still has the FBC problem for instance data. However, it is considerably
easier to manage because (a) it does not have templates or it's version
mismatch-problems, (b) it supports interface programming through
dynamic-dispatch rather than C++ MI (which further compounds field-offset
ABI issues), (c) and instance allocation occurs through dynamic-dispatch
factory methods.

I know it isn't directly relevant to bitc because it's not anywhere close
to typesafe (and it doesn't have any form of generics/parametrics).
However, I think it's interesting to observe that Objective-C *is*
successfully used for modular (DLL) systems programming on MacOS/iOS in a
way that C++ has never succeeded.
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to