From: "Gregory Morrisett" <jgm@cs.cornell.edu>
To: "Pierre Weis" <pierre.weis@inria.fr>,
"Daniel Grossman" <danieljg@sundial.cs.cornell.edu>
Cc: <caml-list@inria.fr>
Subject: RE: [Caml-list] Pattern matcher no more supposed to warn on non exhaustive patterns ?
Date: Thu, 4 Oct 2001 00:29:47 -0400 [thread overview]
Message-ID: <706871B20764CD449DB0E8E3D81C4D4301EE6C00@opus.cs.cornell.edu> (raw)
The issue with threads is a bit more troublesome. Consider:
let x : (int->int) option ref = ref (Some (fun x -> x));;
let foo z =
match z with
{contents=None} -> 0
| {contents=Some(f)} -> f(0);
Now suppose I fork two threads:
Thread 1: foo x
Thread 2: x := None
And suppose that Thread 1 runs long enough that it does the first
match, so it assumes the contents of x is not of the form None.
Now Thread 1 gets descheduled, Thread 2 runs, and sets the
contents of x to None. Then Thread 2 continues with the second
match...
The question is, does Caml core dump because the pattern matcher
assumes that the contents *has* to be a Some(-) in the second
case? Or does it do the derefence and check atomically? Or
does it add a default case that raises a Match exception?
The same thing shows up in SML/NJ with CML. The problem is that
in the presence of threads, you really shouldn't be able to
dereference a mutable value in your patterns.
-Greg
-------------------
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 reply other threads:[~2001-10-04 4:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-04 4:29 Gregory Morrisett [this message]
2001-10-04 7:06 ` Luc Maranget
2001-10-04 8:17 ` Jacques Garrigue
2001-10-04 12:28 ` Xavier Leroy
-- strict thread matches above, loose matches on Subject: below --
2001-10-04 7:36 Damien Doligez
2001-10-04 7:51 ` Einar Karttunen
2001-10-03 17:37 Jean-Marc Eber
2001-10-03 16:54 ` Dan Grossman
2001-10-03 20:52 ` 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=706871B20764CD449DB0E8E3D81C4D4301EE6C00@opus.cs.cornell.edu \
--to=jgm@cs.cornell.edu \
--cc=caml-list@inria.fr \
--cc=danieljg@sundial.cs.cornell.edu \
--cc=pierre.weis@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