Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Jeremy Yallop <yallop@gmail.com>
To: "Milan Stanojević" <milanst@gmail.com>
Cc: "Daniel Bünzli" <daniel.buenzli@erratique.ch>,
	"Jeremie Dimino" <jdimino@janestreet.com>,
	Caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] GADT existential escape
Date: Thu, 19 Mar 2015 17:41:55 +0000	[thread overview]
Message-ID: <CAAxsn=Gjj8dGThYVoq-E7Ne5uJBS-tyX=3g8AO-yHyY+HHtVUw@mail.gmail.com> (raw)
In-Reply-To: <CAKR7PS8DuLUgs7YvDii2te8uhZ9DgpU7NnUNzyUmOnrmN-b_zA@mail.gmail.com>

Daniel Bünzli wrote:
>> N.B. As it stands this is slightly less efficient than using open variants, since you'd have to allocate an exn value for checking equality.

Milan Stanojević:
> Exceptions and open variants are actually exactly the same.

More precisely, the exn type is a particular extensible variant with
some additional syntactic sugar.  The exn type doesn't support GADT
constructors (since it doesn't have type parameters), so it can't be
used to implement the typed keys under discussion -- at least, not in
the same way as Core's extensible-variant-based implementation.

The point here, though, is that Daniel's code allocates:

    match R.E W.w with

while the version using open variants does not allocate:

    match A.Key with

Jeremy.

  parent reply	other threads:[~2015-03-19 17:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-19  0:29 Daniel Bünzli
2015-03-19  0:39 ` Milan Stanojević
2015-03-19  1:07   ` Daniel Bünzli
2015-03-19  1:27     ` Milan Stanojević
2015-03-19 10:44       ` Daniel Bünzli
2015-03-19 11:02         ` Jeremy Yallop
2015-03-19 11:34           ` Daniel Bünzli
2015-03-19 13:22             ` Daniel Bünzli
2015-03-19 16:46             ` Milan Stanojević
2015-03-19 17:14               ` Daniel Bünzli
2015-03-19 17:15                 ` Frédéric Bour
2015-03-19 17:22                   ` Milan Stanojević
2015-03-19 17:41               ` Jeremy Yallop [this message]
2015-03-19 18:29                 ` Alain Frisch
2015-03-19 16:31           ` Milan Stanojević
2015-03-19 11:05         ` Jeremie Dimino
2015-03-19 11:34           ` Daniel Bünzli
2015-03-19 11:59             ` Jeremie Dimino
2015-03-20 13:50               ` Yaron Minsky

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='CAAxsn=Gjj8dGThYVoq-E7Ne5uJBS-tyX=3g8AO-yHyY+HHtVUw@mail.gmail.com' \
    --to=yallop@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=daniel.buenzli@erratique.ch \
    --cc=jdimino@janestreet.com \
    --cc=milanst@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