caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Modules Order
@ 2002-04-18 14:01 Warp
  2002-04-18 14:24 ` Christian Lindig
       [not found] ` <15550.55633.886446.494339@paille.inria.fr>
  0 siblings, 2 replies; 7+ messages in thread
From: Warp @ 2002-04-18 14:01 UTC (permalink / raw)
  To: OCaml

Hi all,

In my last post, I was talking about finding the good order for CMO-linking
when you only got ocamldep output.
I've think about it, and here's some results, please let me know if there is
another/better way.

First of all, the main problem is CMOs have to be linked in the "right"
order, so, if A is calling a function into B, B.cmo has to be passed before
A.cmo in ocamlc arguments.

When you got the following :

A.cmo : A.cmi B.cmi
B.cmo : B.cmi A.cmi

You can't really choose which one of A or B is the first, that's where there
is a "cross".
Now if you have

A.cmi : B.cmi

Then you can say that maybe some function of A is using a type of B. So if
the user doesn't make real cross calls, then you can put A before B
 because B is perhaps calling A )

And if you have both :

A.cmi : B.cmi
B.cmi : A.cmi

Then that's an user design issue :)
Now , let's back to the first sample ( without any dependency between
CMIs ).
If A and B are not then only modules, than there is a way to "guess" the
order.

- First you got your depency tree, composed of ML & MLI files. You need to
add an ML -> ML link when you got a dependency ML -> MLI . If you omit
"supposed crossing" modules ( A & B ) then you're not making any cycle in
you dependency tree.

- Now you try to add the link A.ml -> B.ml , and if that link create a
cycle, then you can say that there is already a way to reach A from B, so
you can guess/hope that the user have a valid design so you have to put
A.cmo before B.cmo and then the conflict is resolved

- if none of the A.ml -> B.ml & B.ml -> A.ml links create a cycle, then you
can't say anything.... ( flip a coin, so linking should work at least 50% of
the time :)

Now I would like to generalize this algorithm with N-crossing-modules. If
anyone got some idea...

Nicolas Cannasse


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Modules Order
  2002-04-18 14:01 [Caml-list] Modules Order Warp
@ 2002-04-18 14:24 ` Christian Lindig
  2002-04-18 14:31   ` Michal Moskal
       [not found] ` <15550.55633.886446.494339@paille.inria.fr>
  1 sibling, 1 reply; 7+ messages in thread
From: Christian Lindig @ 2002-04-18 14:24 UTC (permalink / raw)
  To: Caml Mailing List

On Thu, Apr 18, 2002 at 04:01:33PM +0200, Warp wrote:

> In my last post, I was talking about finding the good order for
> CMO-linking when you only got ocamldep output.  I've think about it,
> and here's some results, please let me know if there is another/better
> way.

I once proposed a sorted output for ocamldep that could be used as the
linking order. The output would be sorted such that files that come
early in the link order also come early in the output. A simple sed
script then could strip away dependencies to get just the file names for
linking.  I still like the idea but my patch for ocamldep that
implemented the topological ordering did not make it into the
distribution.

-- Christian
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Modules Order
  2002-04-18 14:24 ` Christian Lindig
@ 2002-04-18 14:31   ` Michal Moskal
  2002-04-18 14:40     ` Christian Lindig
  0 siblings, 1 reply; 7+ messages in thread
From: Michal Moskal @ 2002-04-18 14:31 UTC (permalink / raw)
  To: Christian Lindig, Caml Mailing List

On Thu, Apr 18, 2002 at 10:24:57AM -0400, Christian Lindig wrote:
> On Thu, Apr 18, 2002 at 04:01:33PM +0200, Warp wrote:
> 
> > In my last post, I was talking about finding the good order for
> > CMO-linking when you only got ocamldep output.  I've think about it,
> > and here's some results, please let me know if there is another/better
> > way.
> 
> I once proposed a sorted output for ocamldep that could be used as the
> linking order. The output would be sorted such that files that come
> early in the link order also come early in the output. A simple sed
> script then could strip away dependencies to get just the file names for
> linking.  I still like the idea but my patch for ocamldep that
> implemented the topological ordering did not make it into the
> distribution.

Maybe just use tsort(1) ? (if you want sed anyway).

-- 
: Michal Moskal :::::::: malekith/at/pld.org.pl :  GCS {C,UL}++++$ a? !tv
: PLD Linux ::::::: Wroclaw University, CS Dept :  {E-,w}-- {b++,e}>+++ h
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Modules Order
  2002-04-18 14:31   ` Michal Moskal
@ 2002-04-18 14:40     ` Christian Lindig
  2002-04-18 14:45       ` Michal Moskal
  0 siblings, 1 reply; 7+ messages in thread
From: Christian Lindig @ 2002-04-18 14:40 UTC (permalink / raw)
  To: Michal Moskal; +Cc: Caml Mailing List

On Thu, Apr 18, 2002 at 04:31:49PM +0200, Michal Moskal wrote:
> Maybe just use tsort(1) ? (if you want sed anyway).

The output of ocamldep uses \ to fold overlong line. This would have to
be undone before input could be fed into tsort. I also had problems
figuring out how tsort works. The documentation for the GNU tsort is
less than clear. Integrating the topological sort into ocamldep is
easier and would benefit platform that do not have tsort.

-- Christian
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Modules Order
       [not found] ` <15550.55633.886446.494339@paille.inria.fr>
@ 2002-04-18 14:41   ` Warp
  2002-04-18 20:55     ` John Max Skaller
  0 siblings, 1 reply; 7+ messages in thread
From: Warp @ 2002-04-18 14:41 UTC (permalink / raw)
  To: Tom Hirschowitz, OCaml

> Does this seem reasonable?
>
> Only put a link in the graph when the dependency is dynamic
> (ie not on types), and build all the cmi files first, so
> that they are available when compiling to cmos.
> Just crash when this graph has a cycle.
>
> I think it's not that difficult, because I did something
> similar for a prototype type-checker for my mixins.
>
> But this supposes to change the way Makefiles are built I guess.
>
> What are your plans about that?

The problem here is that we don't know if we're using either only types or
functions from the other module.
The purpose of that is to enable automatic compilation of one project
composed of many files.

Nicolas Cannasse

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Modules Order
  2002-04-18 14:40     ` Christian Lindig
@ 2002-04-18 14:45       ` Michal Moskal
  0 siblings, 0 replies; 7+ messages in thread
From: Michal Moskal @ 2002-04-18 14:45 UTC (permalink / raw)
  To: Christian Lindig, Caml Mailing List

On Thu, Apr 18, 2002 at 10:40:09AM -0400, Christian Lindig wrote:
> On Thu, Apr 18, 2002 at 04:31:49PM +0200, Michal Moskal wrote:
> > Maybe just use tsort(1) ? (if you want sed anyway).
> 
> The output of ocamldep uses \ to fold overlong line. This would have to
> be undone before input could be fed into tsort. I also had problems
> figuring out how tsort works. The documentation for the GNU tsort is
> less than clear. Integrating the topological sort into ocamldep is
> easier and would benefit platform that do not have tsort.

Ok, I was just curious. (I have never actualy use tsort :)

-- 
: Michal Moskal :::::::: malekith/at/pld.org.pl :  GCS {C,UL}++++$ a? !tv
: PLD Linux ::::::: Wroclaw University, CS Dept :  {E-,w}-- {b++,e}>+++ h
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Modules Order
  2002-04-18 14:41   ` Warp
@ 2002-04-18 20:55     ` John Max Skaller
  0 siblings, 0 replies; 7+ messages in thread
From: John Max Skaller @ 2002-04-18 20:55 UTC (permalink / raw)
  To: Warp; +Cc: Tom Hirschowitz, OCaml

Warp wrote:

>
>The problem here is that we don't know if we're using either only types or
>functions from the other module.
>

One solution to that is to build interfaces containing types
with no corresponding implementation file. Then if you use
a name X for which there is an X.mli but no X.ml,
you're only using types.

This seems like a good policy in general, it is more robust,
since there is no need to keep a duplicated ml and mli file.

Ocaml's ability to process a .mli file with no corresponding
.ml file doesn't appear to be documented... it works for
the native code compiler, don't know about the bytecode
compiler.

If a type is only used locally, the requirement can be relaxed:
in such cases, by specification, some functions must be used
too, so the type can be included in the .ml and mli files.

BTW: the big pain here is functors: using ocamlc -i
to generate an expanded interface for a fuctor application
is really horrible and rarely works properly (you have to edit
the output to replace expanded definitions with aliases
to have any hope of reading it).

Is there a better way?

-- 
John Max Skaller, mailto:skaller@ozemail.com.au
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.
voice:61-2-9660-0850




-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-04-18 21:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-18 14:01 [Caml-list] Modules Order Warp
2002-04-18 14:24 ` Christian Lindig
2002-04-18 14:31   ` Michal Moskal
2002-04-18 14:40     ` Christian Lindig
2002-04-18 14:45       ` Michal Moskal
     [not found] ` <15550.55633.886446.494339@paille.inria.fr>
2002-04-18 14:41   ` Warp
2002-04-18 20:55     ` John Max Skaller

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).