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 TAA15516; Fri, 20 Jul 2001 19:13:55 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA15512 for caml-list@pauillac.inria.fr; Fri, 20 Jul 2001 19:13:47 +0200 (MET DST) 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 LAA05010 for ; Fri, 20 Jul 2001 11:43:30 +0200 (MET DST) Received: from adsl-gw.nexgen-private (ABoulogne-102-1-4-135.abo.wanadoo.fr [193.253.182.135]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f6K9hTP19822 for ; Fri, 20 Jul 2001 11:43:30 +0200 (MET DST) Received: from fabien (fabien.nexgen-private [192.9.200.110]) by adsl-gw.nexgen-private (8.10.2/8.10.2) with SMTP id f6K9OhJ31717 for ; Fri, 20 Jul 2001 11:24:44 +0200 Message-ID: <007d01c11100$432b06d0$6ec809c0@fabien> From: "FabienFleutot" To: "Caml List" References: <3B565E7B.35BB6073@quasar.ipa.nw.ru> Subject: Re: [Caml-list] default values for record field definitions Date: Fri, 20 Jul 2001 11:42:16 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > Why not to introduce a syntax for default values of record fields: > > type rec1 = { attr1: type1 = val1; attr2: type2; attr3: type3 = val3 } > > Why don't you like > type rec1 = { attr1: type1; attr2: type2; attr3: type } > let default_rec1 = { attr1 = init_val1; attr2 = init_val2; attr = init_val3 } > ... > let x = { default_rec1 with attr2 = val2 } That seems to be the most usual workaround, but it'd be nice to allow writing: let x = {default_rec1 with (* Nothing! *) } to produce a copy of default_rec1 instead of a pointer to it, as would do: let x = default_rec1 (useful when there are some mutable fields). It doesn't seem to be difficult to add to the compiler... ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr