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 BAA06081; Thu, 11 Sep 2003 01:19:23 +0200 (MET DST) 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 BAA31007 for ; Thu, 11 Sep 2003 01:19:21 +0200 (MET DST) Received: from mallaury.noc.nerim.net (smtp-104-thursday.noc.nerim.net [62.4.17.104]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h8ANJLf15732 for ; Thu, 11 Sep 2003 01:19:21 +0200 (MET DST) Received: from karryall.dnsalias.org (karryall.dnsalias.org [62.4.18.180]) by mallaury.noc.nerim.net (Postfix) with ESMTP id E928962D35; Thu, 11 Sep 2003 01:19:17 +0200 (CEST) Received: by karryall.dnsalias.org (Postfix, from userid 500) id 60A5D1A0662; Thu, 11 Sep 2003 01:19:20 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16223.45432.216362.752939@karryall.dnsalias.org> Date: Thu, 11 Sep 2003 01:19:20 +0200 From: Olivier Andrieu To: "Eric C. Cooper" Cc: caml-list@inria.fr Subject: Re: [Caml-list] suggestion for record pattern matching and construction In-Reply-To: <20030910185255.GF25815@ecooper.com> References: <20030910185255.GF25815@ecooper.com> X-Mailer: VM 7.17 under Emacs 21.2.1 X-Loop: caml-list@inria.fr X-Spam: no; 0.00; andrieu:01 andrieu:01 caml-list:01 nontrivial:01 camlp:01 oandrieu:01 nerim:01 bindings:01 ocaml:01 labels:01 syntax:02 olivier:02 olivier:02 module:03 contexts:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Eric C. Cooper [Wednesday 10 September 2003] : > > I find that I am often writing code like > { field1 = field1; field2 = field2; field3 = field3 } > when matching and constructing records. I guess it's because thinking > up good names for the record fields is nontrivial and having similar > but different names for the bindings just bothers me. > > How about allowing syntax like that used for labels: > { ~field1; ~field2; ~field3 } > would expand into the above, in both pattern matching and construction > contexts. I have a camlp4 extension that does exactly this (well, without the ~). Also, you can put the module path before the { instead of having to repeat it for each field. So : Mod1.Mod2.{ field1; field2 } is expanded into { Mod1.Mod2.field1 = field1 ; Mod1.Mod2.field2 = field2 } http://oandrieu.nerim.net/ocaml/index.xhtml#pa_records -- Olivier ------------------- 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