Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: Adrien Nader <adrien@notk.org>
Cc: William <r.3@libertysurf.fr>, caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] ocaml 4.03 and warning 52 : argument of this constructor should not be matched against a constant pattern
Date: Wed, 27 Apr 2016 14:20:34 -0400	[thread overview]
Message-ID: <CAPFanBFpu+oDE+AO=92rhtNa14HonZxic9ar=gxQmfk8L=u=SQ@mail.gmail.com> (raw)
In-Reply-To: <20160427171706.GA26005@notk.org>

[-- Attachment #1: Type: text/plain, Size: 2462 bytes --]

If a single call to the binding code can return several of Failure
payloads, then yes, I guess you cannot escape using specific text on the
warning text. You can either disable the warning locally using a @warning
attribute (if your backward-compatibility requirement do not go back before
ppx attributes), or move the string-testing logic to inside the
pattern-matching clause (a guard would also work). Note that the
string-testing solution *can* be made robust if the library/binding exports
identifiers containing the value of the error messages, and you test
against them.

Note that since Benoît Vaugon's optimization work in 4.02.0
pattern-matching on several literal strings is sensibly faster than a
series of string-equality test, so in performance-critical code it makes
sense to use pattern-matching on string -- but it does not need to be part
of the try-handler patterns directly, it can be only in the (Failure err ->
...) clause.

Thanks for your comments (and William's) on the documentation. Feel free to
add additional comments on the related ticket William created, PR#7245
  http://caml.inria.fr/mantis/view.php?id=7245

On Wed, Apr 27, 2016 at 1:17 PM, Adrien Nader <adrien@notk.org> wrote:

> On Wed, Apr 27, 2016, Gabriel Scherer wrote:
> > We now have a section of the reference manual (which has been updated to
> > 4.03) on Warnings, and this particular warning is documented there:
> >   http://caml.inria.fr/pub/docs/manual-ocaml/comp.html#s:comp-warnings
> >
> > Feedback (for example as Mantis tickets) on which warnings are confusing
> > and would deserve additional documentation -- or even patches to provide
> > this documentation -- are warmly welcome.
>
> Thanks for the documentation update. I've found the warning fairly
> confusing and this makes it clear.
>
> As a small note, in a library I use (I won't name it because I haven't
> checked if there were a version more recent than a couple years), C
> bindings use the built-in Failure exception. I guess this is because it
> is so much more convenient when it comes to making C bindings.
> Am I right that such scenario will always trigger this warning because
> the warning attribute will never be removed from the OCaml upstream
> definition of Failure?
>
> PS: my only comment about the warning is maybe to state that all(?)
> exceptions from the stdlib have the corresponding attribute set.
>
> --
> Adrien Nader
>

[-- Attachment #2: Type: text/html, Size: 3123 bytes --]

      reply	other threads:[~2016-04-27 18:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-27  9:22 William
2016-04-27  9:28 ` David Allsopp
2016-04-27  9:36 ` Daniel Bünzli
2016-04-27  9:43   ` Jacques-Henri Jourdan
2016-04-27  9:51     ` Roberto Di Cosmo
2016-04-27 10:00     ` Daniel Bünzli
2016-04-27 10:04       ` Jacques-Henri Jourdan
2016-04-28  7:25         ` Goswin von Brederlow
2016-04-27 11:01 ` Gabriel Scherer
2016-04-27 17:17   ` Adrien Nader
2016-04-27 18:20     ` Gabriel Scherer [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='CAPFanBFpu+oDE+AO=92rhtNa14HonZxic9ar=gxQmfk8L=u=SQ@mail.gmail.com' \
    --to=gabriel.scherer@gmail.com \
    --cc=adrien@notk.org \
    --cc=caml-list@inria.fr \
    --cc=r.3@libertysurf.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