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 QAA30916 for caml-redistribution; Mon, 20 Apr 1998 16:13:54 +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 CAA04848 for ; Fri, 17 Apr 1998 02:27:00 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.8.7/8.8.5) with ESMTP id CAA26137 for ; Fri, 17 Apr 1998 02:26:57 +0200 (MET DST) Received: from localhost (safran.kurims.kyoto-u.ac.jp [130.54.16.91]) by kurims.kurims.kyoto-u.ac.jp (8.8.8/3.6W) with ESMTP id JAA23459 for ; Fri, 17 Apr 1998 09:25:23 +0900 (JST) To: caml-list@pauillac.inria.fr Subject: Re: Non-destructive record update?? In-Reply-To: Your message of "Thu, 16 Apr 1998 16:19:18 +0200 (MET DST)" <199804161419.QAA16455@pauillac.inria.fr> References: <199804161419.QAA16455@pauillac.inria.fr> X-Mailer: Mew version 1.92 on Emacs 20.2 / Mule 3.0 (MOMIJINOGA) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <19980417092601H.garrigue@kurims.kyoto-u.ac.jp> Date: Fri, 17 Apr 1998 09:26:01 +0900 From: Jacques GARRIGUE X-Dispatcher: imput version 971024 Sender: weis From: Pierre Weis Subject: Re: Non-destructive record update?? Date: Thu, 16 Apr 1998 16:19:18 +0200 (MET DST) > We propose the notation {expr with label1 = e1; lable2 = e2 ... } to > mean the record returned by the expression expr with fields label1, > label2, ... set to values e1, e2, ... As long as we are going to discuss syntax, I would suggest: expr.{label1 = e1; label2 = e2; ...} This is just a problem of parsing. With this definition you don't need to change the production rules, just to add a expr ::= expr "." record case to the dot notation. I believe it is also compact and intuitive. And everybody knows how "." associates to the left. Right, I'm overloading "." with another (related) meaning, but "with" is also used elsewhere in the language, and we cannot add keywords forever. By the way the with notation would need non-trivial changes in the parser, since the natural rule produces an ambiguous grammar: { x = y; ... } "x = y" may be parsed either as a field definition or as an expression. If we parse it as an expression, then we are waiting for a "with" clause, and end up with troubles. All right, no such expression may return a record value, so in fact we might modify the definition: { simple expr with label1 = e1; ... } But usually Caml's grammar do not put restriction on expressions between brackets... Jacques, a syntactic MLer --------------------------------------------------------------------------- Jacques Garrigue Kyoto University garrigue at kurims.kyoto-u.ac.jp JG