> On 28 Dec. 2017, at 00:31, Jeremy Yallop <[email protected]> wrote:
> 
> On 27 December 2017 at 05:33, john skaller <[email protected]> wrote:
>> This should be a quicky….
>> 
>> Suppose I have some messy struct in C which is generally used
>> via a pointer. Eg



> 
> The usual way of dealing with this is to define a struct using
> ‘structure' without calling 'field' or 'seal',

I started to do this. But I began to think it was dangerous.

The client of the binding is going to have to do some
low level work to use the binding, which is a bit nasty.
However exposing the structures and letting them poke
about in them feels too dangerous.

And a key struct also uses bitfield :)

In C++ you’d provide a constructor, and some accessor
and mutator methods, and make the actual data private.

In Ocaml, it feels more natural in these cases where
functional operations are favoured to make the structure
opaque, and if necessary for construction, write
some methods in C, and then provide binding to them.


—
john skaller
[email protected]
http://felix-lang.org

_______________________________________________
Ctypes mailing list
[email protected]
http://lists.ocaml.org/listinfo/ctypes

Reply via email to