caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Radu Grigore <radugrigore@gmail.com>
To: Goswin von Brederlow <goswin-v-b@web.de>
Cc: Andreas Rossberg <rossberg@mpi-sws.org>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] mutable and polymorphism
Date: Wed, 15 Sep 2010 20:38:12 +0100	[thread overview]
Message-ID: <AANLkTimdJ7De5FhG=EsG=Tv83msUzMkV_AYhnCHjx=4x@mail.gmail.com> (raw)
In-Reply-To: <878w32g6wh.fsf@frosties.localdomain>

On Wed, Sep 15, 2010 at 8:10 PM, Goswin von Brederlow <goswin-v-b@web.de> wrote:
> In your original a.ml you didn't use the [...]

Let me rephrase. IMO, both the modified a.ml and the modified c.ml
fail for the same reason: polymorphic references. Therefore, just as
you can't infer from "modified a.ml fails" that "original a.ml should
fail" you can also *not* infer from "modified c.ml fails" that
"original c.ml should fail".

> Because the compiler is stupid and things with a ref can't
> polymorphic.

The compiler isn't stupid: Polymorphic references are unsound. See for
example Section 2.2.3 here:
  http://caml.inria.fr/pub/docs/u3-ocaml/ocaml-core.html#toc8

> let f y = let x = ref () in (fun y -> ()) y in f 1; f 'a'

This has different semantics. Consider
  let f y = let x = ref 0 in (fun y -> incr x) y in f 1; f 'a'

In any case, I'm more interested in an explanation of what happens,
since in practice I'm quite happy with a.ml (together with hiding the
reference from outside by not putting it in mli).

regards,
  radu


  reply	other threads:[~2010-09-15 19:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-15 17:10 Radu Grigore
2010-09-15 17:40 ` [Caml-list] " Andreas Rossberg
2010-09-15 17:59   ` Radu Grigore
2010-09-15 19:10     ` Goswin von Brederlow
2010-09-15 19:38       ` Radu Grigore [this message]
2010-09-15 20:44         ` Kaustuv Chaudhuri
2010-09-17  7:31         ` Goswin von Brederlow
2010-09-17 14:04 ` Radu Grigore
2010-09-17 14:08   ` Radu Grigore

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='AANLkTimdJ7De5FhG=EsG=Tv83msUzMkV_AYhnCHjx=4x@mail.gmail.com' \
    --to=radugrigore@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=goswin-v-b@web.de \
    --cc=rossberg@mpi-sws.org \
    /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;
as well as URLs for NNTP newsgroup(s).