From: Xavier Leroy <xavier.leroy@inria.fr>
To: Gregory Morrisett <jgm@cs.cornell.edu>
Cc: Pierre Weis <pierre.weis@inria.fr>,
Daniel Grossman <danieljg@sundial.cs.cornell.edu>,
caml-list@inria.fr
Subject: Re: [Caml-list] Pattern matcher no more supposed to warn on non exhaustive patterns ?
Date: Thu, 4 Oct 2001 14:28:11 +0200 [thread overview]
Message-ID: <20011004142811.E14657@pauillac.inria.fr> (raw)
In-Reply-To: <706871B20764CD449DB0E8E3D81C4D4301EE6C00@opus.cs.cornell.edu>; from jgm@cs.cornell.edu on Thu, Oct 04, 2001 at 12:29:47AM -0400
> 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);
>
> 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?
It reads the "contents" field once, let-binds its value, and use it in
the remainder of the "match":
(function z/52
(let (match/54 (field 0 z/52))
(if match/54 (apply (field 0 match/54) 0) 0))))
Since reading a record field is atomic, no crash can occur: foo either
matches on the "old" or the "new" contents of the reference.
- Xavier Leroy
-------------------
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-04 12:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-04 4:29 Gregory Morrisett
2001-10-04 7:06 ` Luc Maranget
2001-10-04 8:17 ` Jacques Garrigue
2001-10-04 12:28 ` Xavier Leroy [this message]
-- 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=20011004142811.E14657@pauillac.inria.fr \
--to=xavier.leroy@inria.fr \
--cc=caml-list@inria.fr \
--cc=danieljg@sundial.cs.cornell.edu \
--cc=jgm@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