This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Here's a module-dependency analyser


On Thu, 15 Nov 2001, Per Bothner wrote:

> Jocelyn Paine wrote:
> 
> >A nice thing about the javac command is that 'javac *.java' will analyse
> >dependencies between all files and compile them in the correct dependency
> >order.
> >
> Well, to be picky:  It doesn't.  Or at least Iassume it doesn't, because 
> if there
> is a cycle of dependencies (which is common), there is no "correct 
> dependency order".
> Instead it has to process each file in multiple passes:  The first pass 
> collects the
> definitions *provided* by a file.
>
Yes, I should have been more precise. My programming style is such that I
never have them, so their lack doesn't worry me. With Kawa, this is
because I was under the belief that it couldn't do circular dependencies.
If module A requires <B> and B requires <A>, does compiling one of them
for the first time give Kawa any problems? When compiling A, if it comes
across a call of some function which is not in A, how does it know which
class/module to invoke it from and against whose formal parameter list to
check the call? Or if it doesn't, what code does it generate for the call?
A run-time lookup into some kind of environment which it hopes will be
filled also at run-time by the 'require's?

> Kawa does something similar, in that makes two passes of a "body" (i.e.
> a list of definitions and statements as in the body of a function or 
> top-level of a file).
> The first pass "scan" accumulates definitions; the second pass "rewrite"
> uses the definitions from the first pass.  This two-pass approach allows
> us to handle mutually recursive definitions.
> 
> Kawa should do the same when compiling multiple files as it already does for
> a single file.  The first pass would now extend over *all* the files we 
> want to
> compile, and we don't do any further processing until we've "scanned" 
> every file.
> Nothing terribly difficult, but actually doing it is the rub. Until then 
> Jocelyn's
> tool will be useful.
>
I suppose there comes the question of how to identify the dependent files.
If the user asks Kawa to compile, say, /*.scm , would you scan and rewrite
only the files in that set, or would you do all the files implied by their
'require' statements, i.e. a kind of 'remake all' which might extend over
many other directories? The latter would be useful in big projects.

Jocelyn


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]