English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Type annotations
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2000-12-22 (14:25)
From: Pierre Weis <weis@p...>
Subject: Re: Ref syntax
> Really, I don't think it would be useful at toplevel.
> I view let mutable .. in as a way to provide some state, but
> immediately cleanly wrapped, either by only being used locally, or
> in exported functions.
> This is completely similar to mutable object fields; both the goal and
> the method.

I hope this is effectively simple to type check, and ensure correct.

> > For instance, what do we
> > do if such a letref variable is assigned to, from within the body of a
> > function (that could be exported) ?
> This is just syntactic sugar for references, which is why I said it
> was easy. Similarly typing is just the typing of references.

So you mean, that if we define x with let mutable x = 1, the variable
x has in fact type int ref ?

> > Furthermore, this construct would add an entirely
> > new notion to Caml: lvalues.
> As stated above: they are already here, object fields.
> You may think of it as a good or bad idea, but the distinction
> between it and the fact a.x behaves differently when there is a <- and
> when there is none is subtle.

Sorry, but for field mutations the syntactic construct is not
 expr <- new_val
 expr.label <- new_val
which is semantically assign_to_label (expr, new_val), as
 expr.(i) <- new_val
is a short-hand for assign_to_vector (expr, i, new_val).

In both constructs there is no notion of left values.

I really don't know if the corresponding notion for objects needs
lvalues or not.

> But well, this was only first in my wish list because I was answering
> to a message related to that. My personal priority is much lower.

I think exactly the same: the let mutable (or var construct as we used
to call it) is desirable, but may not be worth the implementation

> > So you are already satisfied, since you can write
> > 
> >   ocamlc -c -I +camltk -I +camlimages ocaml_unreal_t.ml
> > 
> > in the current development version!
> Great! I had seen the introduction of -where, but didn't catch this
> one.
> Thanks, Papa Weis !
> Jacques

Hey, this is your ``Santa Xavier's'' work. Thanks to him.


Pierre Weis

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