How compiling circular dependencies works?
Posted
by Fabio F.
on Stack Overflow
See other posts from Stack Overflow
or by Fabio F.
Published on 2010-06-13T16:02:29Z
Indexed on
2010/06/13
16:12 UTC
Read the original article
Hit count: 172
compiler
|circular-dependency
I've made the example in Java but I think (not tested) that it works in other (all?) languages.
You have 2 files M.java that says
public class MType{
XType x;
MType(){ x = null;}
}
and another file XType.java (in the same directory)
public class XType{
MType m;
public XType(MType m){ this.m=m;}
}
Ok it's BAD programming , but.. if you run javac XType it compiles: compiles even MTypes because XType needs it. But.. MType needs XType.. how it works? How does the compiler know what is happening?
Probably is a stupid question, but I would like to know how the compiler (javac or other compilers if you know.) manages that situation, not how to avoid it.
I'm asking because i'm writing a precompiler and I would like to manage that situation..
Thank you
© Stack Overflow or respective owner