[Mono-gc-list] GC and multiple inheritance as in C++

Jason Whittington jasonw at develop.com
Fri Jun 13 14:46:43 EDT 2008


I believe the answer here is: "no".   MI languages have to find a way to
fake it.

 

Microsoft's C++/CLI fakes it by not allowing MI for managed types.   MI
classes are represented as value types in the CLI and thus don't behave with
"true" polymorphism.  They do in the sense that C++ code compiled together
works correctly, but to other languages the inheritance is opaque - calling
GetType().BaseType will just yield System.ValueType.

 

The CLR port of Eiffel fakes it by using a [somewhat complex and arcane]
scheme where inheritance in Eiffel is modeled with interfaces in .NET.

 

Jason

 

 

From: mono-gc-list-bounces at lists.ximian.com
[mailto:mono-gc-list-bounces at lists.ximian.com] On Behalf Of Juro Jon
Sent: Thursday, June 12, 2008 8:36 PM
To: mono-gc-list at lists.ximian.com
Subject: Re: [Mono-gc-list] GC and multiple inheritance as in C++

 

I don't know much of CLI specification so I may be missing something
trivial. Java GC assumes that all pointers point to some "header" to
identity the memory object. Since Java is single inheritance a pointer
always points to the head of a full object, but for C++ multiple inheritance
it may be pointing to an embedded part and need to be adjusted to find the
full object. Are you saying that the CLI GC or typesystem has some way to do
this adjustment?

Thanks

On Fri, Jun 13, 2008 at 3:50 AM, David Jeske <jeske at willowmail.com> wrote:

AFAIK, you don't need C++ MI to have a pointer to something inside an object
body. This can happen if you take a ref of any instance data in C#.

http://www.java2s.com/Code/CSharp/Language-Basics/CRefandOutParameters.htm


-- Juro Jon wrote:
> Hello, I have a question concerning implementation of multiple inheritance
in
> CIL. For a C++ MI object, a pointer can points to inside the object body
> instead of the its head. eg.
> struct A : B, C { };  C* c = new A;
> While Boehm GC detects this kind of reference, is it a supported feature
of
> Mono? If not, what is the suggested way to implement it (eg. what is the
> C++/CLI way) ?

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-gc-list/attachments/20080613/2e2e09ae/attachment.html 


More information about the Mono-gc-list mailing list