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 9E4477EE25 for ; Thu, 24 Oct 2013 16:05:46 +0200 (CEST) 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.214.53; 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.214.53 as permitted sender) identity=mailfrom; client-ip=209.85.214.53; 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-bk0-f53.google.com) identity=helo; client-ip=209.85.214.53; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-bk0-f53.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuADANYoaVLRVdY1lGdsb2JhbABZgz9Uq3aKGIhKgRMIFg4BAQEBBwsLCRIqgiUBAQQBJxkBGxILAQMBCwYFBAcaISEBAREBBQEKEgYTCAqHYgEDCQYNm0SMVoMKhDUKGScDCmSJAQEFDIxTgmoEB4QsA5YfgWuBL4shg0sYKYJmgWs6 X-IPAS-Result: AuADANYoaVLRVdY1lGdsb2JhbABZgz9Uq3aKGIhKgRMIFg4BAQEBBwsLCRIqgiUBAQQBJxkBGxILAQMBCwYFBAcaISEBAREBBQEKEgYTCAqHYgEDCQYNm0SMVoMKhDUKGScDCmSJAQEFDIxTgmoEB4QsA5YfgWuBL4shg0sYKYJmgWs6 X-IronPort-AV: E=Sophos;i="4.93,562,1378850400"; d="scan'208";a="38612615" Received: from mail-bk0-f53.google.com ([209.85.214.53]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 24 Oct 2013 16:05:40 +0200 Received: by mail-bk0-f53.google.com with SMTP id d7so879012bkh.12 for ; Thu, 24 Oct 2013 07:05:45 -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:content-type; bh=8+Zq3AVUHAOiyAHsUVFnYkn4s5X229lk/8MVOfqQwXw=; b=bLQqruyVqToLdKW24MDfxxIS0bbBs9mUcIu4NQxCv2o3P+Y5yblr6iwa3uA5sRiMFJ DrtwyFw+Os33ZcVy7jcWRGmYX2ImUHtaUo17MtZKkOQ9fIRKXAOi6KzdEbATKljjTzOL Nq5k74tOEuUZofkIOcnx32azvHKgxkBupRFwPW1EL5HZ+GSHxwRdPynSHJCgQdJoKnnu GAf056EHwruV6xjUTouGSaYsBJIEIeoxAt8XLIAmfLTVb5E9ow955NIRSXxtCj/N7X1V 5Mfa7Kkro6PcXqGCAth1/d49KUJiskjPPuCciZ08Ub7UdCv3c5PEs9Mnr+QrxySr3T0Q +uiQ== X-Received: by 10.204.55.137 with SMTP id u9mr1932779bkg.28.1382623545481; Thu, 24 Oct 2013 07:05:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.122.72 with HTTP; Thu, 24 Oct 2013 07:05:04 -0700 (PDT) In-Reply-To: <52692507.7040202@gmail.com> References: <52692507.7040202@gmail.com> From: Gabriel Scherer Date: Thu, 24 Oct 2013 16:05:04 +0200 Message-ID: To: Matej Kosik <5764c029b688c1c0d24a2e97cd764f@gmail.com> Cc: caml users Content-Type: multipart/alternative; boundary=001a11c36ab0498c9904e97d21b0 Subject: Re: [Caml-list] strange compiler's tolerance --001a11c36ab0498c9904e97d21b0 Content-Type: text/plain; charset=ISO-8859-1 The pattern _ has been extended to accept any number of arguments. If you think of it type foo = Foo of int * bool let f (Foo _) = () is already quite strange (replacing _ by a variable here doesn't work), but extremely convenient (you don't want to have to remember the constructor's arity just to ignore it). It was extended to 0-ary constructors for consistency, but you can disable this allowance by marking warning 28 (ocamlc -warn-help) as an error. On Thu, Oct 24, 2013 at 3:47 PM, Matej Kosik < 5764c029b688c1c0d24a2e97cd764f@gmail.com> wrote: > Hi, > > Today I noticed a strange compiler's tolerance. > The compiler will not protest here: > > type foo = Bar | Baz > > ;; > > match Bar with > | Bar _ -> () > | Baz -> () > > Why doesn't the compiler protest that I used wildcard after "Bar" > constructor? > (It does protest if I put any other pattern except for the wildcard). > > This slightly breaks the logic. Doesn't it? > > -- > 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 > --001a11c36ab0498c9904e97d21b0 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
The pattern _ has been extended to accept a= ny number of arguments. If you think of it

=A0 type foo =3D Fo= o of int * bool
=A0 let f (Foo _) =3D ()

is already q= uite strange (replacing _ by a variable here doesn't work), but extreme= ly convenient (you don't want to have to remember the constructor's= arity just to ignore it). It was extended to 0-ary constructors for consis= tency, but you can disable this allowance by marking warning 28 (ocamlc -wa= rn-help) as an error.


On Thu, Oct 24, 2013 at 3:4= 7 PM, Matej Kosik <5764c029b688c1c0d24a2e97cd764f@g= mail.com> wrote:
Hi,

Today I noticed a strange compiler's tolerance.
The compiler will not protest here:

=A0 type foo =3D Bar | Baz

=A0 ;;

=A0 match Bar with
=A0 =A0 | Bar _ -> ()
=A0 =A0 | Baz -> ()

Why doesn't the compiler protest that I used wildcard after "Bar&q= uot; constructor?
(It does protest if I put any other pattern except for the wildcard).

This slightly breaks the logic. Doesn't it?

--
Caml-list mailing list. =A0Subscription management and archives:
ht= tps://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners<= /a>
Bug reports:
http://caml.inria.fr/bin/caml-bugs

--001a11c36ab0498c9904e97d21b0--