From: "Petter A. Urkedal" <paurkedal@gmail.com>
To: Gerd Stolpmann <info@gerd-stolpmann.de>
Cc: Martin DeMello <martindemello@gmail.com>,
"caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] Is there an efficient precise ocamldep - Was: why is building ocaml hard?
Date: Sun, 10 Jul 2016 13:51:19 +0200 [thread overview]
Message-ID: <CALa9pHRY1tJhFAM-uLOTw34fZVb=St2U8jkVArT2FApZQ8Rh5w@mail.gmail.com> (raw)
In-Reply-To: <1468150422.25014.75.camel@e130.lan.sumadev.de>
On 10 July 2016 at 13:33, Gerd Stolpmann <info@gerd-stolpmann.de> wrote:
> Rephrasing this question. Given we wanted to develop an improved version
> of ocamldep that (a) reads in cmi files from non-project-local
> directories, and (b) processes all files of the project as a whole, and
> (c) outputs dependencies precisely. Is there an algorithm that is better
> than
>
> - for all permutations p of the project files:
> - env := <modules defined in the non-project-local cmi files>
> - for all files f of p:
> - localenv := []
> - AST := parse f
> - interpret the module calculus of the AST, taking env
> (the toplevel modules) and localenv (the local module
> scope) into account, with these details:
> * if there is an unknown module identifier this is an
> error, and we go on with the next permutation
> * any definition of a module modifies localenv
> * the "open" directive is interpreted strictly using
> env and localenv
> - no error yet:
> - env := env + (f -> localenv)
> (i.e. add the module corresponding to the file to env)
> - if there is a permutation p that doesn't run into an error,
> re-run the dependency analyzer for p and output the deps
> between the (now unambiguously identified) toplevel modules
> (the keys of env)
>
> I think this algorithm is a precise solution to the ocamldep problem
> (well, I did not take mli files into account, but that shouldn't be too
> difficult to add). However, it is horribly inefficient. Is there
> anything better?
I think at least we can reduce upper bound for number of iteration
from n! to n(n-1)/2 by observing that once we find a module which is
successfully analysed, we can keep it for the next iteration: The a
pass over n local files will either succeed in finding a module which
is successfully analysed, leaving n - 1 to be analysed, or fail, in
which case the dependencies are unsatifiable.
next prev parent reply other threads:[~2016-07-10 11:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-10 4:16 [Caml-list] " Martin DeMello
2016-07-10 11:03 ` Gerd Stolpmann
2016-07-10 11:33 ` [Caml-list] Is there an efficient precise ocamldep - Was: " Gerd Stolpmann
2016-07-10 11:51 ` Petter A. Urkedal [this message]
2016-07-10 22:41 ` [Caml-list] " Tom Ridge
2016-07-11 6:15 ` Martin DeMello
2016-07-11 7:22 ` Frédéric Bour
2016-07-11 10:36 ` Gerd Stolpmann
2016-07-13 12:10 ` David Allsopp
2016-07-11 9:14 ` Malcolm Matalka
2016-07-12 8:18 ` Goswin von Brederlow
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='CALa9pHRY1tJhFAM-uLOTw34fZVb=St2U8jkVArT2FApZQ8Rh5w@mail.gmail.com' \
--to=paurkedal@gmail.com \
--cc=caml-list@inria.fr \
--cc=info@gerd-stolpmann.de \
--cc=martindemello@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