caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: Alain Frisch <alain.frisch@lexifi.com>
Cc: Leo White <leo@lpw25.net>, caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] exception Foo = Bar.Baz
Date: Wed, 27 Jul 2016 04:27:15 -0400	[thread overview]
Message-ID: <CAPFanBFxGOVUup8yXpvkDYBXmn019Cboaeeu_C+EFBSZF3wniQ@mail.gmail.com> (raw)
In-Reply-To: <ebddf1c7-9fa5-52c6-c6ec-d1bd748167f9@lexifi.com>

You can already eliminate one of the two comparisons if both A are
statically known to be the same. Moreover, cross-module optimization
information is likely to give you the actual definition of both A and
B -- if they are just defined with either "exception Foo" or
"exception Bar = Baz" as a structure item of the compilation unit
level, their identity will be known. In the complex cases where it is
not (functor parameters, inclusion of a first-class module, etc.), the
cost corresponds to some extra expressiveness for the user that I
think is worth it.

On Wed, Jul 27, 2016 at 4:07 AM, Alain Frisch <alain.frisch@lexifi.com> wrote:
> On 26/07/2016 18:32, Gabriel Scherer wrote:
>>
>> I would see some use in being able to rename variant constructors, see
>>
>>   MPR#7102: Ability to re-export a variant definition with renamed
>> constructors?
>>   http://caml.inria.fr/mantis/view.php?id=7102
>
>
> The fact that an expression "A = B" can evaluate to true can be confusing
> and really change the interpretation of constructors as atoms.  It's already
> the case for exceptions/extension constructors, but I'd prefer to have less
> of it than more.
>
> Thinking more about it, even for exceptions, not allowing different name for
> the same constructor could be useful to optimize cases such as:
>
>
>   try
>
>     try
>      ....
>      raise A
>      ...
>     with B -> ...
>
>   with A -> ....
>
>
> If the compiler could assume that A and B were different constructors, it
> could compile the "raise" to a static jump to the handler for A, removing
> two dynamic comparisons with exception slots (and their associated memory
> accesses).
>
>
> Alain

  reply	other threads:[~2016-07-27  8:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-25 14:34 Matej Kosik
2016-07-25 20:02 ` Alain Frisch
2016-07-25 20:05   ` Gabriel Scherer
2016-07-26  9:36     ` Leo White
2016-07-26 12:37       ` Gabriel Scherer
2016-07-26 16:27         ` Alain Frisch
2016-07-26 16:32           ` Gabriel Scherer
2016-07-27  8:07             ` Alain Frisch
2016-07-27  8:27               ` Gabriel Scherer [this message]
2016-07-27  8:38                 ` Alain Frisch
2016-07-27  8:19           ` Leo White
2016-07-26  9:02   ` Matej Kosik
2016-07-26 12:13     ` Gerd Stolpmann

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=CAPFanBFxGOVUup8yXpvkDYBXmn019Cboaeeu_C+EFBSZF3wniQ@mail.gmail.com \
    --to=gabriel.scherer@gmail.com \
    --cc=alain.frisch@lexifi.com \
    --cc=caml-list@inria.fr \
    --cc=leo@lpw25.net \
    /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).