Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: David Allsopp <dra-news@metastack.com>
To: Timothy Bourke <Timothy.Bourke@inria.fr>,
	"caml-list@inria.fr" <caml-list@inria.fr>
Subject: RE: [Caml-list] ocamlc 4.03 -> 4.04: change in meaning of -i
Date: Sun, 9 Jul 2017 09:47:58 +0000	[thread overview]
Message-ID: <E51C5B015DBD1348A1D85763337FB6D9014D462D9E@Remus.metastack.local> (raw)
In-Reply-To: <20170708140810.vpglvvttlfbflus4@xocuter.home>

Timothy Bourke wrote:
> Sent: 08 July 2017 15:08
> To: caml-list@inria.fr
> Subject: [Caml-list] ocamlc 4.03 -> 4.04: change in meaning of -i
> 
> I just noticed a change in the behaviour of ocamlc that adversely
> affects a tool I maintain.
> 
> In 4.03.0 (and earlier), the -i option only applies to the .ml files
> that follow it on the command line.
> 
> In 4.04.0 (and later), the -i option applies to all .ml files on the
> command line.
> 
> Is this change in behaviour intentional?

This behaviour is a consequence of GPR#464 (in particular https://github.com/ocaml/ocaml/commit/4dc3efe) and intentional.

Prior to 4.04.0, at the point of processing a.ml in `ocamlc a.ml -i b.ml` the compiler assumes it is linking (since that is the default operation) and so generates a.cmo and a.cmi. Once it sees the `-i` it discovers that it's supposed to be dumping interfaces and so prints the interface of b.ml - this works because by fluke it compiled a.ml previously. Prior to 4.04.0, if instead you had run `ocamlc -i a.ml b.ml` (with no a.cmi built) you would have got the same error and the same output.

PR#6475/GPR#464 took the decision that the command line arguments should be fully interpreted before doing anything, hence in 4.04.0+ `ocamlc a.ml -i b.ml` and `ocamlc -i a.ml b.ml` are the same command and interpreted as the latter (the change is marked as breaking as a result).

HTH,


David


> 
> Tim.
> 
> Longer explanation
> ==================
> 
> Given two files.
> 
>   a.ml:
>     let f x = x + 1
> 
>   b.ml:
>     open A
>     let g x = f x
> 
> 1. In 4.03.0 (and earlier), typing either
>      ocamlc a.ml -i b.ml
>    or
>      ocamlc -c a.ml; ocamlc a.ml -i b.ml
> 
>    prints
>      val g : int -> int
> 
>    and generates
>      a.cmi
>      a.cmo
> 
> 2. In 4.04.0 (and later), typing
>      ocamlc a.ml -i b.ml
> 
>    prints
>      val f : int -> int
>      File "b.ml", line 1, characters 5-6:
>      Error: Unbound module A
> 
>    and does not generate anything.
> 
> 3. In 4.04.0 (and later), typing
>      ocamlc -c a.ml; ocamlc a.ml -i b.ml
> 
>    prints
>      val f : int -> int
>      val g : int -> int
> 
>    and generates
>      a.cmi
>      a.cmo


  reply	other threads:[~2017-07-09  9:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-08 14:08 Timothy Bourke
2017-07-09  9:47 ` David Allsopp [this message]
2017-07-09 15:00   ` Timothy Bourke

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=E51C5B015DBD1348A1D85763337FB6D9014D462D9E@Remus.metastack.local \
    --to=dra-news@metastack.com \
    --cc=Timothy.Bourke@inria.fr \
    --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