Hello, I'm a computer science student at the Université Laval in Quebec City. I'm currently following a course on compilers. We're learning semantic analysis at this time and the course is based on the book Compilers: principles, techniques & tools by Alfred V. Aho.
While learning L-attributed SDD, where dependency trees are strictly built from left to right, I wondered if that is why the C programming language requires function prototypes at the top of a file to use functions that are implemented further down. The professor couldn't say and advised me to ask him to do further research on this in private. Instead of making him do the work of figuring out how C compilers work or have worked historically, I thought of coming to one of the most knowledgeable communities on the subject to ask about this. I will share the answers with my professor and classmates, so this is an opportunity to settle the question for many people. I realize that compilers have evolved with time, and that many things required the use of function prototypes, but my question is, what is the historical reason that a function defined further down in a C file cannot be used without a function prototype? A counter-example would be Java, where methods can be defined anywhere in a class and be called even from the constructor. I'm not very interested in Java, so I won't pry much further, but if you know about this, could you quickly explain what it does differently that allows it to do that? Also, is C keeping this behavior to satisfy the standard, or do the modern language analyzers still have the same constraints that required this behavior in the first place? Thank you for your answers, Laurent Cimon