caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David Allsopp <dra-news@metastack.com>
To: "moosotc@gmail.com" <moosotc@gmail.com>
Cc: Gabriel Scherer <gabriel.scherer@gmail.com>,
	caml users <caml-list@inria.fr>
Subject: RE: [Caml-list] Interface(.mli) location
Date: Wed, 10 Aug 2016 08:20:16 +0000	[thread overview]
Message-ID: <E51C5B015DBD1348A1D85763337FB6D90135053024@Remus.metastack.local> (raw)
In-Reply-To: <87k2fpbtud.fsf@gmail.com>

moosotc@gmail.com wrote:
> David Allsopp <dra-news@metastack.com> writes:
> 
> > moosotc@gmail.com wrote:
> >> David Allsopp <dra-news@metastack.com> writes:
> >>
> >> > moosotc@gmail.com wrote:
> >> >> moosotc@gmail.com writes:
> >> >>
> >> >> > moosotc@gmail.com writes:
> >> >> >
> >> >> >> David Allsopp <dra-news@metastack.com> writes:
> >> >> >>
> >> >> > [..snip..]
> >> >> >
> >> >> >>>>
> >> >> >>>> d) Make the compiler skip generation of .cmi if it sees one
> >> >> >>>> in the
> >> -I
> >> >> >>>>    directories?
> >> >> >>>
> >> >> >>> No - I think the use-case is too niche to justify breaking
> >> >> >>> backwards compatibility. That's potentially a very subtle way
> >> >> >>> to break someone else's existing build system. The existing
> >> >> >>> behaviour is precisely documented in the manual (even if it's
> >> >> >>> not necessarily the best approach).
> >> >> >>>
> >> >> >>
> >> >> >> Original post asked for either change of behavior or
> >> >> >> documentation, I failed to find the precise documentation, care
> >> >> >> pointing out where exactly things are described in the manual?
> >> >
> >> > http://caml.inria.fr/pub/docs/manual-ocaml/comp.html#sec263
> >> > describes how .mli and .ml are handled by the compiler (and when
> >> > .cmi is generated or checked against) and the description of -I in
> >> > http://caml.inria.fr/pub/docs/manual-ocaml/comp.html#sec264
> >> > explains that -I only adds search directories for compiled files,
> >> > not source files.
> >>
> >> Thanks, but the manual is completely silent on WHERE it looks for
> >> those files. The issue is not trivial as there are 3 options I can
> >> readily come up with:
> >>      a. current working directory
> >>      b. base directory of -o argument
> >>      c. a set of -I directories
> >>      d. directory where file to be compiled lives
> >>
> >> It looks as if option d. is in effect, but nowhere it is spelled out.
> >
> > Hmm - to my taste the silence says everything required! Options b and
> > c are completely illogical (b would involve inferring an input
> > directory from an output directory and option c contradicts something
> > the manual does state about what -I means). Option a would be
> > surprising behaviour and to my mind is contradicted by the use of "x"
> > in italics 8.1 which to me quite reasonably reads as "change the .ml
> > to .mli" and so include the directory, if there is one. To expect the
> > compiler to look for ./foo.mli when you specified bar/foo.ml would
> > mean you'd changed "x".
> >
> 
> As outlined in the original message, suppose you have the same interface
> but several different implementations (selected during the package
> configuration step for instance), let's call the module Mod.
> 
> Under option d. variants (living in different directories) would each have
> to carry the _same_ mod.mli file in the container directory just to
> satisfy the compilers discovery logic.
> 
> srctree/var1/mod.{ml,mli}
> srctree/var2/mod.{ml,mli}
> 
> instead of potential
> 
> srctree/mod.mli srctree/var1/mod.ml srctree/var2/mod.ml

Yes, I get that - this is starting to feel mutually recursive. As it concerns you hugely, looking again at your original message:

a) Yes, the compiler does expect the .ml and .mli files to be in the same directory
b) Yes, this behaviour is specified in the manual, possibly too mathematically for your tastes, and perhaps benefitting from a cross-reference/extra sentence in section 2.5 to the compiler driver's documentation.
c) No, the compiler does not force you to put .mli files with the .ml files in your use case - it has existing tools which can just about facilitate the layout you're after (see below). They could be improved, though.
d) Lifting the "restriction", for example by allowing -I to search for .mli files, poses a large backwards-compatibility risk.

Of the options I'd already specified, were any of:

a) Add a new command line parameter to make ocamlc/ocamlopt pretend that it found a .mli file with the .ml file (and so use the -I directories to find the .cmi)
b) Abuse the -intf-suffix parameter to achieve the same effect as option a 
c) Put a dummy/empty .mli (not the actual one) in each directory to achieve the same thing

fundamentally unsuitable? You did eliminate the fourth option, which was just to delete the auto-generated .cmi file as with -o you can make it overwrite the actual .cmi file. I'm still puzzled as to why none of those other options yields a solution and the only way to you is a breaking change to the compiler driver or very pedantic updates to the documentation?


David

  reply	other threads:[~2016-08-10  8:20 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-08 16:09 moosotc
2016-08-08 17:03 ` Gabriel Scherer
2016-08-08 17:12   ` Gerd Stolpmann
2016-08-08 17:16   ` moosotc
2016-08-08 18:30     ` David Allsopp
2016-08-08 18:57       ` moosotc
2016-08-08 19:39         ` David Allsopp
2016-08-08 19:59           ` moosotc
2016-08-08 22:54             ` David Allsopp
2016-08-09  8:45               ` SF Markus Elfring
2016-08-09 16:26                 ` David Allsopp
2016-08-09 17:55                   ` SF Markus Elfring
2016-08-09 10:56               ` moosotc
2016-08-09 11:43                 ` moosotc
2016-08-09 11:46                   ` moosotc
2016-08-09 18:08                     ` David Allsopp
2016-08-09 18:35                       ` moosotc
2016-08-09 18:59                         ` David Allsopp
2016-08-09 19:55                           ` moosotc
2016-08-10  8:20                             ` David Allsopp [this message]
2016-08-10 10:38                               ` moosotc
2016-08-09 18:33             ` David Allsopp
2016-08-09 18:38               ` moosotc
2016-08-09 19:02                 ` David Allsopp
2016-08-09  9:22           ` SF Markus Elfring
2016-08-09 16:32             ` David Allsopp
2016-08-09 18:10               ` SF Markus Elfring
2016-08-09 18:26                 ` David Allsopp

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