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 299BA7EE87 for ; Wed, 27 Apr 2016 13:02:30 +0200 (CEST) IronPort-PHdr: 9a23:3KyIexLJlZ+3EBpi0tmcpTZWNBhigK39O0sv0rFitYgULfnxwZ3uMQTl6Ol3ixeRBMOAu6IC27Od6fuocFdDyKjCmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TWM5DIfUi/yKRBybrysXNWC34LnjqvooNX6WEZhunmUWftKNhK4rAHc5IE9oLBJDeIP8CbPuWZCYO9MxGlldhq5lhf44dqsrtY4q3wD88Qa6tVYXK7mU6M9RL1eRHR6YiFmrPHs4CbCSQ+O735UBn9QyTJMAgLI9g3rRYrrvG30rLwu9jOdOJjZRLouWDmmp5xgSBLyhT1PYzEw+nvWh8g2l6lbrQisvTRwxofVZMeeM/8oLfCVRs8TWWcUBpUZbCdGGI7pM9oC 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-ig0-f171.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.213.171; 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.213.171 as permitted sender) identity=mailfrom; client-ip=209.85.213.171; 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-ig0-f171.google.com) identity=helo; client-ip=209.85.213.171; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-ig0-f171.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CLAgD5myBXj6vVVdFeg1Y1fQanNIFRhV2NBiKFbQKBMwc8EAEBAQEBAQEBEQEBAQEHCwsJIS+CLYIVAQEDARIRBBkBGxILAQMBCwYDAgQHGhYHAgIiAREBBQEKEgYTEhCHcgEDCggOlV2PQYExPjGLNoFqgleHNwoZJwMKUYQQAQEBAQEFAQEBAQEBFAEFCgWGEoNJgQKELT2CU4JWBYYzDJFRgVWEJ4gbgjWMXI1yEh6BDg8ogiMeIIFRIDABiS0BAQE X-IPAS-Result: A0CLAgD5myBXj6vVVdFeg1Y1fQanNIFRhV2NBiKFbQKBMwc8EAEBAQEBAQEBEQEBAQEHCwsJIS+CLYIVAQEDARIRBBkBGxILAQMBCwYDAgQHGhYHAgIiAREBBQEKEgYTEhCHcgEDCggOlV2PQYExPjGLNoFqgleHNwoZJwMKUYQQAQEBAQEFAQEBAQEBFAEFCgWGEoNJgQKELT2CU4JWBYYzDJFRgVWEJ4gbgjWMXI1yEh6BDg8ogiMeIIFRIDABiS0BAQE X-IronPort-AV: E=Sophos;i="5.24,541,1454972400"; d="scan'208,217";a="216030270" Received: from mail-ig0-f171.google.com ([209.85.213.171]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 27 Apr 2016 13:02:27 +0200 Received: by mail-ig0-f171.google.com with SMTP id g8so41336396igr.0 for ; Wed, 27 Apr 2016 04:02:27 -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=M+r4wqdSfAz2uZ5A1H/QE5dIhR5dH2CiAGHWf98fm9E=; b=ZZ4mZLlw4OqSQxu4njkYubA806vhv6e1VDo9z8FrDcs6pbyvcn6fYlMnJlV9MWaIT0 zL43hKfcPpA8x4JvozGFEERBtgKUd6BmUhZMlO6eVfP0fRDiNhlb2bQgtP94idvSKWh/ i3yF1X2ei+837HWs13NxpY1ic5tm+lLwaKWmDmZdl5ePZgjqp4Zy+q0E5Bm3NGOdbNMI 8uKIvAAIgqJfjRUplHjwT9daxcj3pJxQVDJ3ds2CeoqHoGYrbYR79b09/u/T8ioCw4HR +hWECHENW8MuKQXAZDiKO1eNhlXyl4yVyZgsJJrRIxcEkq4TKoN0Slk8FWOLrOW2UrFv QaXQ== 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=M+r4wqdSfAz2uZ5A1H/QE5dIhR5dH2CiAGHWf98fm9E=; b=bkYsm54JH+PlK+Jx4VuxgtHBY3Nn6SSx9hYg4P4+s24xkmFCxBojilUQrj5hSspaTL gpOfUqhyWObm5nsSCNuxW1AtgPBAoroHRguMCIsDaXrd9CTmOISj3MLVVsLGcjJw1lX6 tllyqIpOtFgem4ko99BHFv4ulwic0CtNSEDhD83H9D8R88MZ7QbUDzCuUXPdF0FbEE0M SnEU4fPqvekDdPsbZBtidIKR19RKqrjcIAjkMjquqoFXN/WhemQysZigSXXaqkue09I/ s0LDQLzdJX3EVKWz/Spk95QAmdwhFBYkopUqYrAPI1zeCSYu7WK0+1D0rrAgdNhE0Ge7 Mnkg== X-Gm-Message-State: AOPr4FVzkqtpJvOWfsP2Da5SvxL1/P97bJ30v75YixzY6AaOC4p+yQjFVA+VhWxJjHQZfU3LrE5TTPiaf9vt1Q== X-Received: by 10.50.67.113 with SMTP id m17mr20767859igt.62.1461754946164; Wed, 27 Apr 2016 04:02:26 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.89.195 with HTTP; Wed, 27 Apr 2016 04:01:46 -0700 (PDT) In-Reply-To: <572084CC.1080408@libertysurf.fr> References: <572084CC.1080408@libertysurf.fr> From: Gabriel Scherer Date: Wed, 27 Apr 2016 07:01:46 -0400 Message-ID: To: William Cc: caml users Content-Type: multipart/alternative; boundary=047d7bd753ea509c3b05317558e5 Subject: Re: [Caml-list] ocaml 4.03 and warning 52 : argument of this constructor should not be matched against a constant pattern --047d7bd753ea509c3b05317558e5 Content-Type: text/plain; charset=UTF-8 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. On Wed, Apr 27, 2016 at 5:22 AM, William wrote: > Hello, > > with ocaml 4.03, I came with many warnings such as this one : > > let lst = [] in > try > let fst = List.hd lst in > Printf.printf "fst:%s\n" fst > with > | Failure "hd" -> Printf.printf "empty list\n";; > > Characters 123-127: > | Failure "hd" -> Printf.printf "empty list\n";; > ^^^^ > Warning 52: the argument of this constructor should not be matched against > a > constant pattern; the actual value of the argument could change > in the future. > > > > It occurs typically for Failure "hd", Failure "tl", Failure > "float_of_string", Failure "int_of_string", Failure "lexing: empty token", > Invalid_argument "Filename.chop_extension", ... > > How are we supposed to handle this nicely with the standard library ? Is > there a better approach to catch those exceptions ? > > > Best regards, > > William > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > --047d7bd753ea509c3b05317558e5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
We now have a section of the reference manual (which = has been updated to 4.03) on Warnings, and this particular warning is docum= ented there:
=C2=A0 http://caml.inria.fr/pub/docs/manual-ocaml/com= p.html#s:comp-warnings

Feedback (for example as Mantis tic= kets) on which warnings are confusing and would deserve additional document= ation -- or even patches to provide this documentation -- are warmly welcom= e.

On We= d, Apr 27, 2016 at 5:22 AM, William <r.3@libertysurf.fr> wr= ote:
Hello,

with ocaml 4.03, I came with many warnings such as this one :

let lst =3D [] in
try
=C2=A0 =C2=A0let fst =3D List.hd lst in
=C2=A0 =C2=A0Printf.printf "fst:%s\n" fst
with
| Failure "hd" -> Printf.printf "empty list\n";;

Characters 123-127:
| Failure "hd" -> Printf.printf "empty list\n";;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0^^^^
Warning 52: the argument of this constructor should not be matched against = a
constant pattern; the actual value of the argument could change
in the future.



It occurs typically for Failure "hd", Failure "tl", Fai= lure "float_of_string", Failure "int_of_string", Failur= e "lexing: empty token", Invalid_argument "Filename.chop_ext= ension", ...

How are we supposed to handle this nicely with the standard library ? Is th= ere a better approach to catch those exceptions ?


Best regards,

William

--
Caml-list mailing list.=C2=A0 Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocam= l_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

--047d7bd753ea509c3b05317558e5--