Browse thread
native values in objects from c
-
Michael Wohlwend
-
Jacques Garrigue
-
Michael Wohlwend
- Jacques Garrigue
-
Michael Wohlwend
-
Jacques Garrigue
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2006-08-31 (06:55) |
From: | Jacques Garrigue <garrigue@m...> |
Subject: | Re: [Caml-list] native values in objects from c |
From: "Michael Wohlwend" <micha-1@fantasymail.de> > > Well, since fields start at 0, the 3rd field is number 2. > > thanks for helping; actually my fault was to think the elements are linear ordered, even if the class is inherited (I want to get the first value of the base). The values are ordered reverse of definition, whereas the docu says: > "Instance variables are stored in the order in which they appear in the class definition" > > In the end I want to hide public methods which give you access the the pointer to the c++ object and hiding an external method is easy. Aargh, you're right. The behaviour changed between 3.08 and 3.09. In 3.08, fields are still ordered in definition order, including inherited ones, but in 3.09, due to an optimization, inherited fields appear after newly defined ones. The trouble is that this being due to an optimization, this may change again, so it is not a good idea to depend on it. Note also that it is pretty easy to define another object, with the same type as the one you want to interface with C++, but with completely different fields. I.e., accessing object fields from the C side is always dangerous. A better approach it to add a method which returns the field with an abstract type, this way users cannot break the type system. Jacques Garrigue