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

[-- Attachment #1: Type: text/plain, Size: 2147 bytes --]

Thanks for your response.

* David Allsopp [2017-07-09 09:47 +0000]:
> Timothy Bourke wrote:
> > 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.

That commit message is indeed quite clear. I got lost in the other 
ones that were more concerned with .c files.
 
> 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.

I wouldn't have said that it worked by fluke. This design seemed 
reasonable to me (since the order of files is already significant), 
though I admit that it's "trickier" than the new approach.
 
> 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).

OK. Well, I will have to rethink my tool then.

To give a bit more background, the problem concerns the checklistings 
LaTeX package (https://www.ctan.org/pkg/checklistings) which allows 
for compiling code snippets extracted from LaTeX documents. For OCaml 
listings, it is normal to pass the -i option so that the types 
inferred for a code snippet can be displayed in a document. It is also 
normal for later code snippets to depend on earlier ones. The -i 
option, however, does not generate the .cmi file required to compile 
later snippets. My solution was thus to rely on the previous behaviour 
of ocamlc.

Would it be reasonable to have a means of both compiling and showing 
the inferred types? For instance, by passing both -c and -i?

Tim.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

      reply	other threads:[~2017-07-09 15:00 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
2017-07-09 15:00   ` Timothy Bourke [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=20170709150054.vcpwe26fr46khgec@xocuter.home \
    --to=timothy.bourke@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=dra-news@metastack.com \
    /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