Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: Non-destructive record update??
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques GARRIGUE <garrigue@k...>
Subject: Re: Non-destructive record update??
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>