caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: oleg@pobox.com
To: raffalli@univ-savoie.fr
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Resumable exceptions in plain OCaml
Date: Sat, 17 Jun 2006 00:45:52 -0700 (PDT)	[thread overview]
Message-ID: <20060617074552.933DBAC97@Adric.metnet.fnmoc.navy.mil> (raw)
In-Reply-To: <4493239E.2050102@univ-savoie.fr>


Christophe Raffalli observed that

> rraise (Foo i) (function Foo_r1 x -> ... | e -> raise e)

"seems shorter, equivalent and more efficient" than 

>   rraise (Foo i) (fun e -> try raise e with Foo_r1 x -> ...) 

that appeared in the posted code.

I agree. In fact, to the best of my knowledge of the OCaml interpreter,
the former is the semantics of the latter -- or, to be even more
precise, the latter reduces to the former in the interpreter. The
reason I chose the latter is: (i) to avoid writing the default clause
"| e -> raise e", but mainly, (ii) to emphasize the similarity between
pattern matching on the value (when invoking a function, for example) and
pattern matching on the exception in the 'try' clause. The duality
seemed irresistible to pass.

> In fact exceptions in OCaml are one big polymorphic variant type that 
> existed before polymorphic variant where introduced ;-)

So true. One of the motivations for the code resumable.ml was to
(ab)use this fact.

Christophe Raffalli also suggested

>    rraise Foo i with Foo_r1 x -> ...
> is much clearer and certainly possible to define in camlp4 ?

I agree again. I specifically wanted to avoid camlp4 in the original
post, for the sake of naked details. Defining the right syntax, and
implementing it with camlp4, was to be the next step.


  parent reply	other threads:[~2006-06-17  8:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-14 22:54 oleg
2006-06-14 23:46 ` [Caml-list] " Erik de Castro Lopo
2006-06-16 21:33 ` Christophe Raffalli
2006-06-16 21:41   ` Christophe Raffalli
2006-06-17  7:45   ` oleg [this message]
2006-06-18  9:01 ` Dmitry Bely
2006-06-19 21:40   ` oleg

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=20060617074552.933DBAC97@Adric.metnet.fnmoc.navy.mil \
    --to=oleg@pobox.com \
    --cc=caml-list@inria.fr \
    --cc=raffalli@univ-savoie.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;
as well as URLs for NNTP newsgroup(s).