From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 131F97EE7C for ; Wed, 27 Apr 2016 20:21:16 +0200 (CEST) IronPort-PHdr: 9a23:K9Mc7hfcJAix6rFfY0cNvlNelGMj4u6mDksu8pMizoh2WeGdxc69bR7h7PlgxGXEQZ/co6odzbGG4+awAydcsN6oizMrTt9lb1c9k8IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUiv2OQc9HOnpAIma153xjLDivc2JKFkZzBOGIppMbzyO5T3LsccXhYYwYo0Q8TDu5kVyRuJN2GlzLkiSlRuvru25/Zpk7jgC86l5r50IeezAcq85Vb1VCig9eyBwvZWz9EqLcQzaz3cGU2gQ2jxBDwXfpEXzUo3wvy3SsO1h22+dJ8KgHp4uXjH3wK5hUh7ljG88PD406mzNwph/hahBoR+l4Qd0w4PObZu9O/93f6ebdtQfEzkSFv1NXjBMV9vvJ7AECPAMaKMB99Hw Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=gabriel.scherer@gmail.com; spf=Pass smtp.mailfrom=gabriel.scherer@gmail.com; spf=None smtp.helo=postmaster@mail-io0-f176.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.223.176; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.223.176 as permitted sender) identity=mailfrom; client-ip=209.85.223.176; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-io0-f176.google.com) identity=helo; client-ip=209.85.223.176; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-io0-f176.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0A3AAAzAiFXkLDfVdFEGoQLfQaFQakiiwMBDYF1IoQWgVcCgSsHOBQBAQEBAQEBAREBAQEBBw0JCSEvgi2CFAEBAQMBEhEEGQEbHQEDAQsGBQsNIwcCAiIBEQEFARwGExsHh3IBAwoIDiykA4ExPjGLNoFqgleHNgoZJw1RhBABAQEBAQUBAQEBAQEUAQUKBYYShEuELYMQglYFjVSFOIUEgVWEJ4gbgWdOiCOEOYYkUYZ9Eh6BDg8PAQGCOh4ggVEgMAGJLQEBAQ X-IPAS-Result: A0A3AAAzAiFXkLDfVdFEGoQLfQaFQakiiwMBDYF1IoQWgVcCgSsHOBQBAQEBAQEBAREBAQEBBw0JCSEvgi2CFAEBAQMBEhEEGQEbHQEDAQsGBQsNIwcCAiIBEQEFARwGExsHh3IBAwoIDiykA4ExPjGLNoFqgleHNgoZJw1RhBABAQEBAQUBAQEBAQEUAQUKBYYShEuELYMQglYFjVSFOIUEgVWEJ4gbgWdOiCOEOYYkUYZ9Eh6BDg8PAQGCOh4ggVEgMAGJLQEBAQ X-IronPort-AV: E=Sophos;i="5.24,542,1454972400"; d="scan'208,217";a="216093745" Received: from mail-io0-f176.google.com ([209.85.223.176]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 27 Apr 2016 20:21:14 +0200 Received: by mail-io0-f176.google.com with SMTP id 190so49019154iow.1 for ; Wed, 27 Apr 2016 11:21:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=wGja6U/pIz6i5ll3+HZuFJZH8psPcotx/wmrNZkIw+4=; b=VNC8OqGIkETM5l4HCWyAkx3tnS7CHifK2hui+RudGOzURBGs8waExImaJWmUDqzexD ucjP/mIccVQorfsolH6eZLpYDrqHmXx/lO5ntF9Onpu2ItWYBHrLUJ0K6JRKSh6AT48u xu2g6k/ROpfkpVcHdoHvaCY9GkDa180GRzzRc4fY0uKPegW8YPADn1hn0kLvxaO2AUb0 N+Hc61e+TFP3S5WmdmGV00jrW7z5oXBwrAcFISlYyps78wRmKWDhkitX0UtHp/G3yso8 05zQ7Xl7elo+Cwim5kWn4DvC3OOIepvlUVRvrOY7u7NdanWEaYEi0By+9pIe6qPtUUJm +l5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=wGja6U/pIz6i5ll3+HZuFJZH8psPcotx/wmrNZkIw+4=; b=cpL+AU6xEmHxNFe3bIgY8MrRnGZyOpaj2axWgwdSEBPlicPKQfJi6O19D1J/Qb6yQN WyWdpSDzRhFWL9yCyA7hUktuSMzQgg/fVU4CatL4ZYR5JclGRojwWW2RwNiNz+ugGtrq A3s9CE5VXZmFBAK4XGHJQiEjpb70UMtp/KWjixVlXxIRciTeMIaDOjPdaXW6QWYCjDSD osgCHwranKMGA+Gq/i9DhNbu2mI8+QcKiyUI4VOdFR2KC3MsbuH11uNh6/lbyK2fZtXg I/K91GqgdkIBCEk77oW3MtNaE1a9bXQZGp+0mlCZX/gKFRGohZkq05AihnyEdBLgZLwI XuBw== X-Gm-Message-State: AOPr4FWnIttdVuyjWs/6AV4HSJCLOZeosf2ojD+SDVGgYcE2SjuZeV2VR46xwUwOJTWVOdHd9bAdg4urB3yqAg== X-Received: by 10.107.169.13 with SMTP id s13mr11424973ioe.19.1461781273485; Wed, 27 Apr 2016 11:21:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.89.195 with HTTP; Wed, 27 Apr 2016 11:20:34 -0700 (PDT) In-Reply-To: <20160427171706.GA26005@notk.org> References: <572084CC.1080408@libertysurf.fr> <20160427171706.GA26005@notk.org> From: Gabriel Scherer Date: Wed, 27 Apr 2016 14:20:34 -0400 Message-ID: To: Adrien Nader Cc: William , caml users Content-Type: multipart/alternative; boundary=001a11427aa88ba7ae05317b7988 Subject: Re: [Caml-list] ocaml 4.03 and warning 52 : argument of this constructor should not be matched against a constant pattern --001a11427aa88ba7ae05317b7988 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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=C3=AEt 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=3D7245 On Wed, Apr 27, 2016 at 1:17 PM, Adrien Nader 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 > --001a11427aa88ba7ae05317b7988 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
If a single call to the binding code can return = several of Failure payloads, then yes, I guess you cannot escape using spe= cific text on the warning text. You can either disable the warning locally = using a @warning attribute (if your backward-compatibility requirement do n= ot go back before ppx attributes), or move the string-testing logic to insi= de the pattern-matching clause (a guard would also work). Note that the str= ing-testing solution *can* be made robust if the library/binding exports id= entifiers containing the value of the error messages, and you test against = them.

Note that since Beno=C3=AEt Vaugon's optimization wo= rk 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&#= 39;s) on the documentation. Feel free to add additional comments on the rel= ated ticket William created, PR#7245
=C2=A0 http://caml.inria.fr/mantis/view.php?id=3D72= 45

O= n 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:
>=C2=A0 =C2=A0http://caml.inr= ia.fr/pub/docs/manual-ocaml/comp.html#s:comp-warnings
>
> Feedback (for example as Mantis tickets) on which warnings are confusi= ng
> and would deserve additional documentation -- or even patches to provi= de
> this documentation -- are warmly welcome.

Thanks for the documentation update. I've found the warning fair= ly
confusing and this makes it clear.

As a small note, in a library I use (I won't name it because I haven= 9;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

--001a11427aa88ba7ae05317b7988--