caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Leo P White <lpw25@cam.ac.uk>
To: Andreas Rossberg <rossberg@mpi-sws.org>
Cc: Andrej Bauer <Andrej.Bauer@andrej.com>, caml <caml-list@inria.fr>
Subject: Re: [Caml-list] Proposal for extensible open datatypes
Date: 06 Jan 2012 09:24:38 +0000	[thread overview]
Message-ID: <Prayer.1.3.4.1201060924380.15105@hermes-2.csi.cam.ac.uk> (raw)
In-Reply-To: <8ED26AE5-A208-49A2-A8CD-43F22E969FF9@mpi-sws.org>

On Jan 6 2012, Andreas Rossberg wrote:

>On Jan 6, 2012, at 07.26 h, Andrej Bauer wrote:
>> I would be interested to hear what propeties of Ocaml you had to give
>> up to get this interesting extension working? For example, what
>> happens with checking for exhaustivness of match? Caml performs
>> various optimizations in pattern matching, why are those still ok now
>> that new alternatives may appear later?
>
>One such type is already in ML, for historical reasons it happens to  
>be named exn. Consequently, you don't really give up anything, your  
>questions already apply to the exception type. Exhaustiveness simply  
>requires a catch-all in all pattern matches over this type. More  
>difficult is irredundancy, because constructors can be aliased without  
>the type system tracking that (and it cannot across module  
>boundaries). You have to give up there.
>
>Generalising exn this way is an old idea, e.g. we implemented it in  
>Alice ML. The standard reply to requesting such an extension is that  
>it's not really needed, because you can already do everything using  
>exn (though without custom type distinctions, and minus GADTs in OCaml).

Yes, it uses the same same pattern matching as exn. This means that a 
catch-all pattern is required for exhaustiveness, and if-then-elses are 
used instead of jump tables.

The problem would become a bit more interesting if ordinary variant types 
could also be made open, thus allowing types to have both ordinary 
constructors and extensions, but the patch doesn't support that yet.

Leo


      reply	other threads:[~2012-01-06  9:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-06  0:32 Leo P White
2012-01-06  6:26 ` Andrej Bauer
2012-01-06  8:56   ` Andreas Rossberg
2012-01-06  9:24     ` Leo P White [this message]

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=Prayer.1.3.4.1201060924380.15105@hermes-2.csi.cam.ac.uk \
    --to=lpw25@cam.ac.uk \
    --cc=Andrej.Bauer@andrej.com \
    --cc=caml-list@inria.fr \
    --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).