From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 46197BB9C for ; Wed, 21 Dec 2005 11:41:47 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jBLAfkxJ019079 for ; Wed, 21 Dec 2005 11:41:46 +0100 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 LAA07851 for ; Wed, 21 Dec 2005 11:41:45 +0100 (MET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jBLAfhA3019075 for ; Wed, 21 Dec 2005 11:41:45 +0100 Received: from localhost (suiren [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.13.1/8.13.1) with ESMTP id jBLAfclm024189; Wed, 21 Dec 2005 19:41:39 +0900 (JST) Date: Wed, 21 Dec 2005 19:41:37 +0900 (JST) Message-Id: <20051221.194137.12318829.garrigue@math.nagoya-u.ac.jp> To: eizneckam@gmail.com Cc: skaller@users.sourceforge.net, caml-list@inria.fr Subject: Re: [Caml-list] syntax bug: copying records From: Jacques Garrigue In-Reply-To: References: <1135142554.18811.16.camel@rosella> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 43A9316A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 43A93167.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 syntax:01 bug:01 dup:01 notation:01 wrote:01 sourceforge:01 workaround:01 jacques:01 jacques:01 segmentation:02 garrigue:03 garrigue:03 let:03 perhaps:03 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 From: Mackenzie Straight > On 12/20/05, skaller wrote: > > If x is a record then { x } should be a copy of it. But this > > doesn't work, I am using this ugly workaround instead: > > > > { x with dummy_field = x.dummy_field } > > > > Surely there is a better way? > > Perhaps: > > let copy (x:'a) = (Obj.obj (Obj.dup (Obj.repr x)) : 'a) Not a very good idea: # copy 3;; Segmentation fault This also explains why you need at least one record field in the "with" notation, otherwise there is no way to know for sure the type of the record you're copying. Jacques Garrigue