Re: Non-destructive record update??

From: Jacques GARRIGUE (garrigue@kurims.kyoto-u.ac.jp)
Date: Fri Apr 17 1998 - 02:26:01 MET DST


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>
Message-Id: <19980417092601H.garrigue@kurims.kyoto-u.ac.jp>
Date: Fri, 17 Apr 1998 09:26:01 +0900
From: Jacques GARRIGUE <garrigue@kurims.kyoto-u.ac.jp>

From: Pierre Weis <Pierre.Weis@inria.fr>
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
                <A HREF=http://wwwfun.kurims.kyoto-u.ac.jp/~garrigue/>JG</A>



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:14 MET