caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David Allsopp <dra-news@metastack.com>
To: Hongbo Zhang <hzhang295@bloomberg.net>,
	"gabriel.scherer@gmail.com" <gabriel.scherer@gmail.com>
Cc: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: RE: [Caml-list] Justifying a breaking 4.03 change, strong dependency on modules with "external" declarations (was: )
Date: Mon, 16 May 2016 12:38:40 +0000	[thread overview]
Message-ID: <E51C5B015DBD1348A1D85763337FB6D9F04FA591@Remus.metastack.local> (raw)
In-Reply-To: <5739B475020502AA00390319_0_12595@p057>

Hongbo Zhang wrote:

> My 2 cents: I did not like this change, for modules which has side effect, it should always
> be explicitly listed in the link line, instead of relying on such fragile implicit behavior.

I think Gabriel's explanation has missed an important subtlety of the original problem. One of the reasons you might "omit" the .cmx file when linking is because you thought you'd given it, because the .cmx file was in a .cmxa file which you had linked (or more likely, one which ocamlfind was adding thanks to -package and -linkpkg instructions...).

Even worse, even if you did specify Bar.cmx, the linker did nothing to ensure that you'd placed it *before* the first call to an external value - meaning that the primitive could be called before the required initialisation code.

The only workarounds were to use val instead of external (giving both a slight performance penalty and forcing a .mli file to be written - although many, me included, think .mli files should be mandatory anyway!) or to use -linkall, which is not necessarily feasible.

I remember wasting a lot of time the first time I got stung by that... even though it is in the manual. In fact, that means the first paragraph of the manual needs updating!


David


PS I noticed that the old behaviour still happens with normal primitives (e.g. %identity), but I guess that's intentional? 

  reply	other threads:[~2016-05-16 12:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-16 11:52 Hongbo Zhang (BLOOMBERG/ 731 LEX)
2016-05-16 12:38 ` David Allsopp [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-05-16  1:09 Gabriel Scherer

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=E51C5B015DBD1348A1D85763337FB6D9F04FA591@Remus.metastack.local \
    --to=dra-news@metastack.com \
    --cc=caml-list@inria.fr \
    --cc=gabriel.scherer@gmail.com \
    --cc=hzhang295@bloomberg.net \
    /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;
as well as URLs for NNTP newsgroup(s).