From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA05161; Wed, 6 Mar 2002 11:54:38 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA04744 for ; Wed, 6 Mar 2002 11:54:38 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g26AsbL16214; Wed, 6 Mar 2002 11:54:37 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA05259; Wed, 6 Mar 2002 11:54:36 +0100 (MET) Date: Wed, 6 Mar 2002 11:54:36 +0100 From: Xavier Leroy To: Warp Cc: OCaml Subject: Re: [Caml-list] Tuple copy Message-ID: <20020306115436.A4830@pauillac.inria.fr> References: <008c01c1c477$f2a9ef60$3000a8c0@warp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <008c01c1c477$f2a9ef60$3000a8c0@warp>; from warplayer@free.fr on Tue, Mar 05, 2002 at 07:59:58PM +0100 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > I got the following question : I have a type MSG wich is allocated using > alloc_tuple(3) , and contains one Int and two Int32. > Sometimes, the second Int32 is a C pointer, so I managed to garbage it by > allocating sometimes MSG using alloc_tuple(4) and then storing a custom > block in the fourth block (this custom block hold the C pointer, and will > free() it when garbaged - the C pointer is also stored as an Int32 in the > MSG to enable its access by C API ). So for the same type MSG, i'm mixing > tuple of different sizes. > > Does this can cause problems ? It won't crash the program. The GC "sees" the fourth field and handles it correctly, while the Caml code never "sees" it (it trusts the type declaration that says that the result is a triple). However, primitives such as generic equality might return unexpected results (but again they won't crash). For instance, a 3-tuple MSG will never be equal to a 4-tuple MSG, even though both agree on the first 3 fields (and thus print identically under the toplevel, for instance). - Xavier Leroy ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners