caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Caml sur Rhapsody
@ 1998-04-09 15:02 Pierre Weis
  1998-04-14 23:27 ` Non-destructive record update?? Donald Syme
  0 siblings, 1 reply; 6+ messages in thread
From: Pierre Weis @ 1998-04-09 15:02 UTC (permalink / raw)
  To: caml-list

[English version follows.]

Nous sommes heureux d'annoncer la disponibilite d'Objective Caml version
1.07 pour le système d'exploitation Rhapsody sur Macintosh.

Il s'agit d'un portage complet qui inclut le compilateur
optimisant. Il est disponible sous forme d'un fichier de patch,
par FTP anonyme a l'endroit habituel:

machine: ftp.inria.fr (192.93.2.54)
repertoire: lang/caml-light/ocaml-1.07-rhapsody.diff

url: ftp://ftp.inria.fr/lang/caml-light/ocaml-1.07-rhapsody.diff

Veuillez envoyer vos rapports d'anomalies a caml-light@pauillac.inria.fr.

Damien Doligez
Xavier Leroy
Pierre Weis

[English version:]

It is our pleasure to announce the release of Objective Caml version 1.07
for the Macintosh under the Rhapsody operating system.

This is a complete port, including the native code compiler. It is
available as a patch file via anonymous ftp at:

host: ftp.inria.fr (192.93.2.54)
directory: lang/caml-light/ocaml-1.07-rhapsody.diff

url: ftp://ftp.inria.fr/lang/caml-light/ocaml-1.07-rhapsody.diff

Bug reports should be mailed to caml-light@pauillac.inria.fr.

Damien Doligez
Xavier Leroy
Pierre Weis





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Non-destructive record update??
  1998-04-09 15:02 Caml sur Rhapsody Pierre Weis
@ 1998-04-14 23:27 ` Donald Syme
  1998-04-25 11:26   ` Christophe Raffalli
  0 siblings, 1 reply; 6+ messages in thread
From: Donald Syme @ 1998-04-14 23:27 UTC (permalink / raw)
  To: caml-list


[Sorry - wrong subject on previous message]

I think O'Caml is absolutely excellent in general, but 
why doesn't it have some form of non-destructive record
field update, as in

type x = {y : int};;
let x = {y=1};;
(x.y <- 2).y = 2;;  (* true *)
x.y = 1;;           (* true *)

????  (well, at least I haven't found it if it does...)

If I have N fields in my records, and if I need non-destructive update
because I'm actually writing things functionally (rather common in
a functional language), then I end up writing N*N lines worth of
non-destructive update functions myself - yeach!  

Thanks in advance,
Don Syme

-- 
-----------------------------------------------------------------------------
At the lab:                                          At home:
The Computer Laboratory                              Trinity Hall
New Museums Site                                     CB2 1TJ
University of Cambridge                              Cambridge, UK
CB2 3QG, Cambridge, UK
Ph: +44 (0) 1223 334688                             
http://www.cl.cam.ac.uk/users/drs1004/
email: drs1004@cl.cam.ac.uk
-----------------------------------------------------------------------------







^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Non-destructive record update??
  1998-04-25 11:26   ` Christophe Raffalli
@ 1998-04-16 14:19     ` Pierre Weis
  1998-04-16 14:47       ` Pascal Brisset
  1998-04-17  0:26       ` Jacques GARRIGUE
  0 siblings, 2 replies; 6+ messages in thread
From: Pierre Weis @ 1998-04-16 14:19 UTC (permalink / raw)
  To: Christophe.Raffalli; +Cc: Donald.Syme, caml-list

> The syntax could be
> 
> *   x.y <- 2 (may be confusing with mutable syntax ?)
> 
> *   let y = 2 in record x 
> 
> Or anything else, but there really should be something !

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, ...

This is reminiscent of the usual (functionnal) notation for records,
and does not confuse with field update.

As an example, you may define functionnal translations for points as:

type point = {x : float; y : float; color : int};;

let translate q = {q with x = q.x +. 1.0};;

As an additional benefit, this notation provides a simple way to
define default values for records fields. For example:

let default_point = {x = 0.0; y = 0.0; color = black};;

let p = {default_point with x = 2.0};;

> With the second syntax it is easy to extend the parser, 
> and you could have a "and" to update more than one field, with only one copy
> of the original record:
> 
>     let y = 2 and z = 3 in record x
> 
>  This is not the case with the straight forward compilation of:
> 
>     (x.y <- 2).z <- 3

This new way of defining records is also straightforward to compile.

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/







^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Non-destructive record update??
  1998-04-16 14:19     ` Pierre Weis
@ 1998-04-16 14:47       ` Pascal Brisset
  1998-04-17  0:26       ` Jacques GARRIGUE
  1 sibling, 0 replies; 6+ messages in thread
From: Pascal Brisset @ 1998-04-16 14:47 UTC (permalink / raw)
  To: Pierre Weis; +Cc: Christophe.Raffalli, Donald.Syme, caml-list

Pierre Weis writes:
> 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, ...

 Is it a good idea to ``hide'' the copy of one object behind a simple
keyword ? I think such operation should be more explicit. Something with
the 'new' keyword like

	new expr with {label1 = e1; lable2 = e2 ... }

makes things a bit clearer.

 Anyway, a function Record.copy would be enough !

--Pascal





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Non-destructive record update??
  1998-04-16 14:19     ` Pierre Weis
  1998-04-16 14:47       ` Pascal Brisset
@ 1998-04-17  0:26       ` Jacques GARRIGUE
  1 sibling, 0 replies; 6+ messages in thread
From: Jacques GARRIGUE @ 1998-04-17  0:26 UTC (permalink / raw)
  To: caml-list

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>





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Non-destructive record update??
  1998-04-14 23:27 ` Non-destructive record update?? Donald Syme
@ 1998-04-25 11:26   ` Christophe Raffalli
  1998-04-16 14:19     ` Pierre Weis
  0 siblings, 1 reply; 6+ messages in thread
From: Christophe Raffalli @ 1998-04-25 11:26 UTC (permalink / raw)
  To: Donald Syme; +Cc: caml-list


I completely agree with that.

You can end up with a messy program when you want to update record in a 
functional way. Moreover, if you add one field to a record type you have to 
modify your program for each updating even if they are unrelated with the new 
field !

The syntax could be

*   x.y <- 2 (may be confusing with mutable syntax ?)

*   let y = 2 in record x 

Or anything else, but there really should be something !

With the second syntax it is easy to extend the parser, 
and you could have a "and" to update more than one field, with only one copy
of the original record:

    let y = 2 and z = 3 in record x

 This is not the case with the straight forward compilation of:

    (x.y <- 2).z <- 3
   


-- 
Christophe Raffalli
Laboratoire de Mathématique / LAMA
Université de Savoie
UFR SFA, Campus Scientifique
73376, Le Bourget du Lac CEDEX, FRANCE.

URL: http://www.logique.jussieu.fr/www.raffalli
email: Christophe.Raffalli@univ-savoie.fr






^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1998-04-20 14:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-09 15:02 Caml sur Rhapsody Pierre Weis
1998-04-14 23:27 ` Non-destructive record update?? Donald Syme
1998-04-25 11:26   ` Christophe Raffalli
1998-04-16 14:19     ` Pierre Weis
1998-04-16 14:47       ` Pascal Brisset
1998-04-17  0:26       ` Jacques GARRIGUE

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).