From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: Matej Kosik <5764c029b688c1c0d24a2e97cd764f@gmail.com>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] strange compiler's tolerance
Date: Thu, 24 Oct 2013 16:05:04 +0200 [thread overview]
Message-ID: <CAPFanBH41CbRFyT71qgQE9q8UAbS6ct6mFFuVoEFrhgh4mXr8w@mail.gmail.com> (raw)
In-Reply-To: <52692507.7040202@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1324 bytes --]
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<https://sympa.inria.fr/sympa/arc/caml-list>
> Beginner's list: http://groups.yahoo.com/group/**ocaml_beginners<http://groups.yahoo.com/group/ocaml_beginners>
> Bug reports: http://caml.inria.fr/bin/caml-**bugs<http://caml.inria.fr/bin/caml-bugs>
>
[-- Attachment #2: Type: text/html, Size: 2032 bytes --]
next prev parent reply other threads:[~2013-10-24 14:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-24 13:47 Matej Kosik
2013-10-24 14:02 ` Pippijn van Steenhoven
2013-10-24 14:05 ` Gabriel Scherer [this message]
2013-10-24 14:35 ` Virgile Prevosto
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=CAPFanBH41CbRFyT71qgQE9q8UAbS6ct6mFFuVoEFrhgh4mXr8w@mail.gmail.com \
--to=gabriel.scherer@gmail.com \
--cc=5764c029b688c1c0d24a2e97cd764f@gmail.com \
--cc=caml-list@inria.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