caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: Chet Murthy <murthy.chet@gmail.com>
Cc: Jeremy Yallop <yallop@gmail.com>, Oleg Kiselyov <oleg@okmij.org>,
	Mailing List OCaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Are record types generative?
Date: Wed, 24 Jan 2018 17:43:20 +0900	[thread overview]
Message-ID: <4C24893D-6053-4F0D-BFDD-DF76172E64F9@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <CA++P_gfHDiw1xSME6BOL_wZcja6=LrB4h60Z3LeL-kqEEuPnYg@mail.gmail.com>

On 2018/01/24 10:05, Chet Murthy wrote:
> 
> On Tue, Jan 23, 2018 at 2:06 PM, Jeremy Yallop <yallop@gmail.com> wrote:
> IHere's a closely
> related property that's much harder to break: does adding annotations
> leave the run-time behaviour of a program unchanged?  There are far
> fewer programs that violate that property, I think.
> 
> I'm no longer a type-theorist, so I don't have the knowledge to answer, but:
> 
> It was a critically important property of *all* the original MLs (and of the theoretical development of ML) that a well-type ML program P could be "type-erased" to an untyped program TE(P); then when P -eval-> V, and TE(P) -eval-> V', TE(V) == V'.  Where's I'm abusing notation, b/c "-eval->" means in the first case "evaluation on typed programs" and in the second, "evaluation on untyped programs" which might be entirely different things.
> 
> This was the (famous amongst that admittedly tiny community) "commuting rectangles type erasure property”.

This property is still true in OCaml (minus Obj.magic, but Obj.magic is not valid OCaml :-).
I.e., types can be used to optimize a program, but they do not change its semantics.
It’s true of so-called “overloaded” record labels, it’s true of a labeled and default arguments
(which use type information for compilation, but not semantics), it’s true of objects,
 it’s true of GADT pattern-matching (again optimized), etc…

> A -concrete- effect of this property in MLs (again, I'm no longer a type-theorist, so I might be getting this wrong) is ML-family languages don't support reflection, and when they support object-orientation, they don't support "instanceof" (e.g. like Java's).  because these require that compile-time type-information be present at runtime.

Indeed, as soon as we add type classes, type witnesses or (type-selected) implicit arguments, this property is lost.

> For those who think this is a bad design choice, I can only say that as a systems-jock, I appreciate a language that is -so- high-level, and -yet- can easily be programmed in such a way that I can understand the runtime behaviour in terms of a C-like runtime model.  By contrast, to understand Java *for real* one must have enormously detailed knowledge of the JVM -- the particular JVM implementation -- one is using.


Indeed.

Jacques

  reply	other threads:[~2018-01-24  8:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-23 14:54 Oleg
2018-01-23 16:05 ` Jeremy Yallop
2018-01-23 17:39   ` Chet Murthy
2018-01-23 20:35     ` Jeremy Yallop
2018-01-23 21:36       ` Chet Murthy
2018-01-23 22:06         ` Jeremy Yallop
2018-01-23 23:14           ` Hendrik Boom
2018-01-24  1:06             ` Chet Murthy
2018-01-24  1:35             ` Francois BERENGER
2018-02-07  2:00               ` [Caml-list] [ANN] first release of bst: a bisector tree implementation Francois BERENGER
2018-02-07 12:40                 ` Ivan Gotovchits
2018-02-08  0:46                   ` Francois BERENGER
2018-01-24  1:56             ` [Caml-list] Are record types generative? Yawar Amin
2018-01-25 10:49               ` Matej Košík
2018-01-25 13:39                 ` Simon Cruanes
2018-01-25 16:24                 ` Yawar Amin
2018-01-24  1:05           ` Chet Murthy
2018-01-24  8:43             ` Jacques Garrigue [this message]
2018-02-02 23:07               ` Toby Kelsey
2018-02-02 23:23                 ` Evgeny Roubinchtein
2018-02-04  1:27                 ` Jacques Garrigue

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=4C24893D-6053-4F0D-BFDD-DF76172E64F9@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=murthy.chet@gmail.com \
    --cc=oleg@okmij.org \
    --cc=yallop@gmail.com \
    /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).