From: Pierre Chambart <pierre.chambart@ocamlpro.com>
To: "Richard W.M. Jones" <rich@annexia.org>,
Gabriel Scherer <gabriel.scherer@gmail.com>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Are refs volatile?
Date: Wed, 04 Nov 2015 15:56:47 +0000 [thread overview]
Message-ID: <563A2ABF.9040506@ocamlpro.com> (raw)
In-Reply-To: <20151104152339.GP3006@annexia.org>
On 04/11/2015 15:23, Richard W.M. Jones wrote:
> On Wed, Nov 04, 2015 at 04:08:48PM +0100, Gabriel Scherer wrote:
>> I find the question hard to understand, so I may have missed a subtlety in
>> the code you have shown.
> It's very possible I don't know what I'm talking about, but
> this is my analysis:
>
>>> List.iter (
>>> fun task ->
>>> if not !quit then task ();
>>> ) tasks;
> Suppose that the optimizer can see the contents of `task', and see
> that it cannot update the quit variable. In that case, could it
> assume that quit is a constant, and hoist the test outside the loop?
> ie. transforming the code to:
>
> if not !quit then (
> List.iter (
> fun task ->
> task ();
> ) tasks
> )
>
> Rich.
>
No. There is no specified semantic of ocaml, but in any reasonable
semantics of it won't be allowed.
I won't write something that could do that, and I would consider it a
bug if it happened.
--
Pierre Chambart
prev parent reply other threads:[~2015-11-04 15:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-04 12:43 Richard W.M. Jones
2015-11-04 13:18 ` Gerd Stolpmann
2015-11-04 15:08 ` Gabriel Scherer
2015-11-04 15:23 ` Richard W.M. Jones
2015-11-04 15:56 ` Pierre Chambart [this message]
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=563A2ABF.9040506@ocamlpro.com \
--to=pierre.chambart@ocamlpro.com \
--cc=caml-list@inria.fr \
--cc=gabriel.scherer@gmail.com \
--cc=rich@annexia.org \
/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