From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA21748 for caml-red; Wed, 15 Nov 2000 22:38:50 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA01752 for ; Wed, 15 Nov 2000 00:28:33 +0100 (MET) Received: from relay.wplus.net (relay.wplus.net [195.131.52.179]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id eAENSW907532 for ; Wed, 15 Nov 2000 00:28:32 +0100 (MET) X-Real-To: caml-list@inria.fr Received: from kouzdra.glokaya (ip86-202.dialup.wplus.net [195.131.86.202]) by relay.wplus.net (8.9.1/8.9.1/wplus.2) with ESMTP id CAA11628; Wed, 15 Nov 2000 02:22:49 +0300 (MSK) Received: from localhost (msk@localhost) by kouzdra.glokaya (8.9.3/8.9.3) with ESMTP id AAA32609; Wed, 15 Nov 2000 00:31:03 +0300 X-Authentication-Warning: kouzdra.glokaya: msk owned process doing -bs Date: Wed, 15 Nov 2000 00:31:03 +0300 (MSK) From: Anton Moscal X-Sender: msk@kouzdra.glokaya To: stephanh@win.tue.nl cc: caml-list@inria.fr Subject: Re: Is this use of Object.magic safe? In-Reply-To: <00111310044001.28230@pcrm> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: weis@pauillac.inria.fr On Mon, 13 Nov 2000, Stephan Houben wrote: > I have three questions: > 1. Is this safe w.r.t. the garbage collector? Or am I going to confuse the GC? > 2. Can I safely marshall values? > 3. Is it worth the trouble? Perhaps O'Caml already does something smart > when a constructor of the form `Int of int' is encountered? Answers for 1 & 2 is true, for 3 - false: if you try to run the following program: let _ = Printf.printf "%b\n" (value_of_int 0 == value_of_allocated_value True) you got "true" as the result. The cause is the following: variant without arguments represented in the same way with int's. Correct solution will be: type allocated_value = Bool of bool | String of string | Array of value Regards, Anton Moscal