Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* le GC et les bidouilles en C
@ 1999-08-05  8:58 Patrick Goldbronn - SYSCO
  0 siblings, 0 replies; 2+ messages in thread
From: Patrick Goldbronn - SYSCO @ 1999-08-05  8:58 UTC (permalink / raw)
  To: Inria, caml

Bonjour,

Je me pose une question sur les manipulations des structures caml en C

Je déclare un type record :
------------------
type toto = {
	un : float array ;
	deux : int ;
} ;;
------------------

Je déclare une variable de type toto :
------------------
let mytoto = {
	un = Array.create 10 0. ;
	deux = 0 ;
} in
------------------

J'appelle une fonction C bidouilleC qui modifie le contenu de mytoto:
------------------
bidouilleC mytoto ;;
------------------


Le code C de bidouilleC :
------------------
un_v = Field(mytoto_v,0) ;

for (i=0,i<10;i++) 
  Store_double_field(un_v,i,Val_int(i)) ;
(* ca c'est bon je suppose, en fait on peut le faire avec n'importe quel
tableau avec la fonction modify *)
------------------

Le probleme est avec deux !
On doit faire, je suppose :
modify(&Field(mytoto_v,1),Val_int(1)) ;

Il n'y a pas besoin de declarer "deux" mutable ?

Est-ce que l'on peut utiliser cette méthode sur tous les types record et
tuple qui ont le tag 0 meme si les veleurs ne sont pas mutables (je
parle d'un point de vu technique, pas philosophique) ?

Merci pour votre aide.

-- 
#####################################
# Patrick GOLDBRONN                 #
# CEA - DRN/DMT/SYSCO               #
# CE-Saclay, Bâtiment 460           #
# 91191 GIF/YVETTE CEDEX (FRANCE)   #
#                                   #
# Tél : 01 69 08 40 66              #
# Fax : 01 69 08 96 96              #
#####################################




^ permalink raw reply	[flat|nested] 2+ messages in thread
* Re:  le GC et les bidouilles en C
@ 1999-08-20 15:57 Damien Doligez
  0 siblings, 0 replies; 2+ messages in thread
From: Damien Doligez @ 1999-08-20 15:57 UTC (permalink / raw)
  To: patrick.goldbronn; +Cc: caml-list

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 509 bytes --]

>From: Patrick Goldbronn - SYSCO <patrick.goldbronn@cea.fr>

>Je déclare un type record :
>type toto = {
>        un : float array ;
>        deux : int ;
>} ;;

>modify(&Field(mytoto_v,1),Val_int(1)) ;

ou bien:

   Store_field (mytoto_v, 1, Val_int (1));


>Il n'y a pas besoin de declarer "deux" mutable ?

Dans l'implementation actuelle, non, MAIS il est facile d'imaginer des
optimisations qui seraient cassees par cette absence de declaration.

Donc il vaut mieux declarer "deux" mutable.

-- Damien




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-08-22 19:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-05  8:58 le GC et les bidouilles en C Patrick Goldbronn - SYSCO
1999-08-20 15:57 Damien Doligez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox