From: Dan Grossman <danieljg@cs.cornell.edu>
To: Luc Maranget <luc.maranget@inria.fr>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Pattern matcher no more supposed to warn on non
Date: Wed, 03 Oct 2001 14:23:13 -0400 [thread overview]
Message-ID: <3BBB5791.F2B66FC6@cs.cornell.edu> (raw)
In-Reply-To: <200110031807.UAA0000026808@beaune.inria.fr>
Luc Maranget wrote:
> Argl....
>
> Dear Dan, which result would you consider to be correct ?
> (1111 ?)
> Please tell me...
> (Note that I see no consitency either in 3.02 or 3.00,)
>
> Cheers, thanks, and argl again !
>
> --Luc
If this problem is worth fixing, I suggest that only 1111 or 4444 are
reasonable answers. I tend to prefer 1111. For fixing the
exhaustiveness-checker and pattern-compiler, it's probably easiest to do the
most expensive thing: the presence of a when clause basically invalidates
the failure of all previous cases -- it's like they weren't there.
Note that no change needs to be made except when the pattern's type includes
a mutable field.
Further note that threads are even harder to deal with -- they effectively
can put evil when clauses everywhere. My familiarity with the ocaml
run-time is rusty, but perhaps a pattern-match (where the pattern's type
includes a mutable field) could be "rolled back" when the thread is
restarted. Of course, you can't re-execute any when clauses! :-)
--Dan
>
> It is worth a warning in the manual, at least...
>
> >
> > ===============
> >
> > type y = {mutable c:bool}
> > type x = {a:y; b:y}
> >
> > let f1 (v:x) =
> > match v with
> > {a = _; b = _} when (v.a.c <- false; v.b.c <- false; false) -> 0
> > | {a = {c=false}; b = {c=false}} -> 1
> > | {a = {c=false}; b = {c=true}} -> 2
> > | {a = {c=true}; b = {c=false}} -> 3
> > | {a = {c=true}; b = {c=true}} -> 4
> >
> > let f2 (v:x) =
> > match v with
> > {a = {c=true}; b = _} when (v.a.c <- false; v.b.c <- false; false) -> 0
> > | {a = {c=false}; b = {c=false}} -> 1
> > | {a = {c=false}; b = {c=true}} -> 2
> > | {a = {c=true}; b = {c=false}} -> 3
> > | {a = {c=true}; b = {c=true}} -> 4
> >
> > let f3 (v:x) =
> > match v with
> > {a = _; b = {c=true}} when (v.a.c <- false; v.b.c <- false; false) -> 0
> > | {a = {c=false}; b = {c=false}} -> 1
> > | {a = {c=false}; b = {c=true}} -> 2
> > | {a = {c=true}; b = {c=false}} -> 3
> > | {a = {c=true}; b = {c=true}} -> 4
> >
> > let f4 (v:x) =
> > match v with
> > {a = {c=true}; b={c=true}} when (v.a.c <- false; v.b.c <- false; false)
> > -> 0
> > | {a = {c=false}; b = {c=false}} -> 1
> > | {a = {c=false}; b = {c=true}} -> 2
> > | {a = {c=true}; b = {c=false}} -> 3
> > | {a = {c=true}; b = {c=true}} -> 4
> >
> > let main () =
> > let v1:x = {a = {c=true}; b = {c=true}} in
> > let v2:x = {a = {c=true}; b = {c=true}} in
> > let v3:x = {a = {c=true}; b = {c=true}} in
> > let v4:x = {a = {c=true}; b = {c=true}} in
> > print_int (f1 v1);
> > print_int (f2 v2);
> > print_int (f3 v3);
> > print_int (f4 v4)
> >
> > let _ = main ()
> > -------------------
> > Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
> > To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
> >
--
| Dan Grossman www.cs.cornell.edu/home/danieljg H:607 256 0724 |
| 5157 Upson Hall danieljg@cs.cornell.edu O:607 255 9834 |
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
next prev parent reply other threads:[~2001-10-03 18:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-03 17:37 [Caml-list] Pattern matcher no more supposed to warn on non exhaustive patterns ? Jean-Marc Eber
2001-10-03 16:54 ` Dan Grossman
2001-10-03 18:07 ` [Caml-list] Pattern matcher no more supposed to warn on non Luc Maranget
2001-10-03 18:23 ` Dan Grossman [this message]
2001-10-03 20:52 ` [Caml-list] Pattern matcher no more supposed to warn on non exhaustive patterns ? Pierre Weis
2001-10-04 7:55 ` Luc Maranget
2001-10-04 9:06 ` Luc Maranget
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=3BBB5791.F2B66FC6@cs.cornell.edu \
--to=danieljg@cs.cornell.edu \
--cc=caml-list@inria.fr \
--cc=luc.maranget@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