Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Pierre Weis <Pierre.Weis@inria.fr>
To: Xavier Leroy <Xavier.Leroy@inria.fr>
Cc: caml-list@inria.fr
Subject: Re: cyclic value construction ("let rec")
Date: Mon, 10 Apr 2000 02:03:08 +0200	[thread overview]
Message-ID: <20000410020308.18555@pauillac.inria.fr> (raw)
In-Reply-To: <20000406162552.49765@pauillac.inria.fr>; from Xavier Leroy on Thu, Apr 06, 2000 at 04:25:52PM +0200

> > > This certainly suggests to allow the export of an immutable view of a
> > > record type with mutable fields. This way you could do the

> Alas, it can do a lot of harm.  For one thing, you could break type
> safety this way, just like with polymorphic references:
[...]
> So, no, we can't allow exporting a record with different mutability
> annotations than in its definition.

This is perfectly right, and as always with mutable values, you cannot
implement a feature without adding some safeguard conditions.

That's why I suggested to export an immutable VIEW of a record type
with mutable fields, not simply to export it as an immutable type!

I was thinking of something like:

type 'a loc = {mutable contents : 'a} as {contents : 'a};;

This way the compiler knows everything about the type, the original
and ``view'' definitions, so that nothing can be invalidated. The gain
is that now, direct assignment as

    x.contents <- value

is forbidden, and values of loc cannot be assigned outside their
definition module, if this module carefully avoids to export any
assignment function.

Evidently, values of type ref should be considered mutable by the
compiler, for instance during the constant propagation pass.

This view conception of type exportation could also be generalized to
hide some other information about a type to export: hide some
constructors or labels...
-- 
Pierre Weis

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



  parent reply	other threads:[~2000-04-10  0:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-30 20:12 Benoit Deboursetty
2000-04-03 12:57 ` Markus Mottl
2000-04-06 13:18   ` Pierre Weis
2000-04-06 13:34     ` Markus Mottl
2000-04-06 14:25       ` Xavier Leroy
2000-04-06 15:12         ` Markus Mottl
2000-04-10  0:03         ` Pierre Weis [this message]
2000-04-10  1:41           ` Markus Mottl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20000410020308.18555@pauillac.inria.fr \
    --to=pierre.weis@inria.fr \
    --cc=Xavier.Leroy@inria.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox