From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: xcforum@free.fr
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Question about polymorphic variants
Date: Mon, 07 Nov 2005 12:11:02 +0900 (JST) [thread overview]
Message-ID: <20051107.121102.78704390.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <4CB7BAE5-122C-4241-B744-F9D1F5F3D96D@free.fr>
From: Xavier Clerc <xcforum@free.fr>
> Thanks for your answer, I start to grasp how existence of "top" can
> be related to related to my question.
> However, I must confess that I am still puzzled by the fact that your
> example heavily rely on the actual representations of elements and
> not only on their types.
> A question is still pending in my mind (in fact, always the same
> question, reformulated to sound like I am making some progress) : if
> the compiler(s) where patched to treat all arrays either as boxed or
> as unboxed, would it be safe to get rid of the leading underscore in
> the inferred type ?
Possibly. That is, only if there is nothing else in the representation
of values that makes impossible to assume the existence of top.
This counter-example is simple enough, but to check that top is sound
one would have to check the whole compiler and libraries.
The point is that, if you do not require the existence of top from the
beginning, you may end up doing lots of things that make it impossible
to add it later.
> Equivalently, is the use of "top" (using Obj.repr and relatives)
> unsafe only because of concrete representation or for theoretical
> reason ?
Theory is only a way to prove that practice is correct.
There is no theoretical reason not to have top (one can design a
sound theory with top), but if practice does not allow to add top,
then theory does not allow us to generalize contravariant type
variables.
Put differently, it had been known that the existence of top would
matter, implementation might have been different. Or the conclusion
might have been that assuming top would be too much of a burden in
practice, and it might have been intentionally dropped anyway. Not
allowing a compiler to change representation according to types can be
seen as rather drastic, even if Objective Caml doesn't do it a lot.
Jacques Garrigue
next prev parent reply other threads:[~2005-11-07 3:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-28 9:57 Xavier Clerc
2005-10-28 11:59 ` [Caml-list] " Jacques Garrigue
2005-10-28 12:27 ` Xavier Clerc
2005-10-29 0:26 ` Jacques Garrigue
2005-10-31 17:08 ` Xavier Clerc
2005-11-01 0:27 ` Jacques Garrigue
2005-11-04 13:20 ` Xavier Clerc
2005-11-07 3:11 ` Jacques Garrigue [this message]
2005-11-07 13:39 ` Xavier Clerc
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=20051107.121102.78704390.garrigue@math.nagoya-u.ac.jp \
--to=garrigue@math.nagoya-u.ac.jp \
--cc=caml-list@inria.fr \
--cc=xcforum@free.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