Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Jeffrey Scofield <jeffsco@psellos.com>
To: caml-list@inria.fr
Subject: [Caml-list] Re: Interfacing with C: bad practice
Date: 16 Aug 2011 11:55:43 -0500	[thread overview]
Message-ID: <m3wredcn3k.fsf@pse.psellos.com> (raw)
In-Reply-To: <4E4A9C17.7060605@gmail.com>

Török Edwin <edwintorok@gmail.com> writes:

> But isn't this 'f(g(), x)' issue the same as the classic example
> of undefined behaviour with f(++i, ++i)?

It's not quite the same, because a function call (g())
introduces a sequence point.  In the f(++i, ++i) case,
I think there's only a sequence point after the call
to f.

I personally think the effect of f(x, g()) is unspecified
if g() changes the value of x.  I don't think the compiler
is required to chase down dependencies like this, that's why
the order of parameter passing is left unspecified.

I've often worried about exactly this case when writing
OCaml/C interfaces.

I'm far from an expert, however.

(One great thing about the ML family is that there
are exceptionally clear answers to questions like this.
Especially for Standard ML.)

Jeffrey


  parent reply	other threads:[~2011-08-16 16:56 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-16  7:37 [Caml-list] " Dmitry Bely
2011-08-16  8:04 ` Török Edwin
2011-08-16  8:25   ` Dmitry Bely
2011-08-16  8:43     ` Török Edwin
2011-08-16  9:46       ` rixed
2011-08-16  9:53         ` Dmitry Bely
2011-08-16 10:17           ` Török Edwin
2011-08-16 11:04             ` rixed
     [not found] ` <20110816.105738.246515733851238101.Christophe.Troestler@umons.ac.be>
2011-08-16  9:21   ` Dmitry Bely
2011-08-16 10:39     ` Mauricio Fernandez
2011-08-16 14:27       ` John Carr
2011-08-16 12:28 ` [Caml-list] " Dmitry Bely
2011-08-16 15:25 ` [Caml-list] " Richard W.M. Jones
2011-08-16 15:51   ` rixed
2011-08-16 16:00     ` Will M. Farr
2011-08-16 16:10     ` Richard W.M. Jones
2011-08-16 16:17       ` Richard W.M. Jones
2011-08-16 16:18       ` Dmitry Bely
2011-08-16 16:22         ` Richard W.M. Jones
2011-08-16 16:27           ` Richard W.M. Jones
2011-08-16 16:30             ` malc
2011-08-16 16:34             ` Török Edwin
2011-08-16 16:47               ` Richard W.M. Jones
2011-08-16 16:55               ` Jeffrey Scofield [this message]
2011-08-16 17:08                 ` [Caml-list] " Will M. Farr
2011-08-16 19:46                 ` Gerd Stolpmann
2011-08-16 20:18                   ` Jeffrey Scofield
2011-08-16 17:08       ` [Caml-list] " rixed
2011-08-16 16:06   ` John Carr
2011-08-16 16:14     ` Wojciech Meyer
2011-08-16 16:13   ` Dmitry Bely

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=m3wredcn3k.fsf@pse.psellos.com \
    --to=jeffsco@psellos.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