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-25 (21:10)
From: qrczak@k...
Subject: Re: Ref syntax
Fri, 22 Dec 2000 10:07:07 +0100 (MET), Pierre Weis <Pierre.Weis@inria.fr> pisze:

> Furthermore, this construct would add an entirely new notion to
> Caml: lvalues.

It would not necessarily cause troubles. "let mutable x = init_value
in expr" would be equivalent to "let ref_x = ref init_value in expr",
where x is a *macro* visible inside expr, expanding to ref_x.contents
in all contexts, before desugaring expressions of the form
variable.field <- something.

So for example "let y = x in ..." placed inside expr would bind the
snapshot of x's value to y, and "let y () = x in ..." would create
a function which retrieves the current x's value each time it is
called. No more confusing than usual eager evaluation order.

There is no direct access to ref_x itself.

IMHO it's perfectly consistent with mutable record fields.

 __("<  Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
  ^^                      SYGNATURA ZASTĘPCZA