Requiring a specific order of compilaiton

Posted by Aber Kled on Programmers See other posts from Programmers or by Aber Kled
Published on 2013-10-22T21:37:22Z Indexed on 2013/10/22 22:01 UTC
Read the original article Hit count: 146

When designing a compiled programming language, is it a bad idea to require a specific order of compilation of separate units, according to their dependencies?

To illustrate what I mean, consider C. C is the opposite of what I'm suggesting. There are multiple .c files, that can all depend on each other, but all of these separate units can be compiled on their own, in no particular order - only to be linked together into a final executable later.

This is mostly due to header files. They enable separate units to share information with each other, and thus the units are able to be compiled independently.

If a language were to dispose of header files, and only keep source and object files, then the only option would be to actually include the unit's meta-information in the unit's object file.

However, this would mean that if the unit A depends on the unit B, then the unit B would need to be compiled before unit A, so unit A could "import" the unit B's object file, thus obtaining the information required for its compilation.

Am I missing something here? Is this really the only way to go about removing header files in compiled languages?

© Programmers or respective owner

Related posts about programming-languages

Related posts about c