English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
native values in objects from c
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-08-29 (13:32)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] native values in objects from c
From: "Michael Wohlwend" <micha-1@fantasymail.de>

> with that code:
> 
> class x = object
>  val name = "hoho"
> end;;
> 
> let ho = new x in ...
> 
> 
> how do I access the field name form C? 
> 
> The docu says it should be the third field of the block, but that doesn't work for me (it has Tag 0, not 252 for strings ...)

Well, since fields start at 0, the 3rd field is number 2.

# Obj.size (Obj.repr ho);;
- : int = 3
# Obj.tag (Obj.field (Obj.repr ho) 2);;                    
- : int = 252

Jacques Garrigue