[Mono-osx] NObjective and Inheritance
Rodrigo Kumpera
kumpera at gmail.com
Wed Feb 18 21:31:11 EST 2009
On Wed, Feb 18, 2009 at 10:48 PM, Eugeny Grishul
<eugeny.grishul at gmail.com>wrote:
>
> Hi Martin!
>
> 2Rodrigo:
> >Encoding a OO type hierarchy using valuetypes is plain wrong.
> What about C++? Each class and struct is a value type but with inheritance
> ability (and some others). Are programmers that designing their apps in C++
> wrong?. Value types is most efficient way to combine memory management
> schemes of Objective-C and Mono (see perftest on NObjective's main page).
>From a type safe perspective, subtyping and valuetypes simply don't match.
C++
is a good example of an incredibly broken language - type slicing is a good
example
of how brain-dead the language is when it comes to type safety.
The core issue is that subtyping requires reference semantics to be safe and
provable correct.
Correctness comes first of performance.
> Some of users told me that they don't want to attach to the Objective-C
> object using managed counterpart, but want work with it as raw pointer.
> Only
> value types can provide such ability.
>
Well, they can always use IntPtr for that. No need for any hackery.
> >It's not a bug in mono, the CLR is designed this way and there is no
> compeling reason to implement such broken behavior.
> Mono bug is crashes while accessing of virtual methods of boxed object that
> not derived from ValueType/Enum. CLR ( CLR = MS CLI implementation ) able
> to
> run such code and I have no idea why Mono JIT team can't emulate such
> behaviour. Also CLR runtime verifier accepts such code coz it's VALID CIL
> (but not verifiable).
>
This is simply not true. A simple example shows you the opposite [1]. The
issue
is that your're abusing the CTS and the standard make guarantees on what
happens
when executing such code.
But OTOH, we are always open to contributions from the community in case you
want to fix mono.
>
> Mono internally used a thousands of different hacks so using of vtypes not
> directly inherited from ValueType/Enum isn't criminal.
>
This is not an argument, it's an excuse.
Cheers,
Rodrigo
[1] As for:
public interface Foo {
int Value();
}
public struct Bar : Foo {
int val;
public Bar(int x) { this.val = x; }
public int Value() {
return val;
}
}
public class Driver {
static void Main () {
Foo f = new Bar (10);
Console.WriteLine (f.Value ());
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20090218/8e61473b/attachment.html
More information about the Mono-osx
mailing list