From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 620CBBB9C for ; Wed, 21 Dec 2005 12:01:00 +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 jBLB0x1U021599 for ; Wed, 21 Dec 2005 12:00:59 +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 MAA08860 for ; Wed, 21 Dec 2005 12:00:59 +0100 (MET) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jBLB0vPE021596 for ; Wed, 21 Dec 2005 12:00:58 +0100 Received: from rosella (ppp33-4.lns1.syd2.internode.on.net [59.167.33.4] (may be forged)) by smtp3.adl2.internode.on.net (8.12.9/8.12.6) with ESMTP id jBLB0ipO034713; Wed, 21 Dec 2005 21:30:44 +1030 (CST) (envelope-from skaller@users.sourceforge.net) Subject: Re: [Caml-list] syntax bug: copying records From: skaller To: Jacques Garrigue Cc: eizneckam@gmail.com, caml-list@inria.fr In-Reply-To: <20051221.194137.12318829.garrigue@math.nagoya-u.ac.jp> References: <1135142554.18811.16.camel@rosella> <20051221.194137.12318829.garrigue@math.nagoya-u.ac.jp> Content-Type: text/plain Date: Wed, 21 Dec 2005 22:00:43 +1100 Message-Id: <1135162843.8939.7.camel@rosella> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 43A935EB.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 43A935E9.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 syntax:01 bug:01 notation:01 expr:01 expr:01 inference:01 lexing:01 lexbuf:01 wrote:01 wrote:01 sourceforge:01 sourceforge:01 imho:01 workaround:01 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 On Wed, 2005-12-21 at 19:41 +0900, Jacques Garrigue wrote: > 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? > 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. Why not? If I write let x = expr in ... then the type of x is determined by the type of expr unified with the uses of x, right? So the same inference doesn't apply to let x = { expr } in .. instead, { .. } is required to have a definite type? Couldn't this be checked instead, so that one could write: let x = { expr : thetype } in which IMHO is preferable to picking one of the fields, since the latter is fragile wrt the names of the fields. How would you copy Lexing.lexbuf .. whose contents could be construed as implementation dependent? Or worse .. a private record type .. which you *cannot* copy with functional update .. although perhaps one could argue if there is no copy constructor given it shouldn't be copyable .. hmm. -- John Skaller Felix, successor to C++: http://felix.sf.net