How compilers know about other classes and their properties?

Posted by OnResolve on Programmers See other posts from Programmers or by OnResolve
Published on 2012-06-27T21:02:24Z Indexed on 2012/06/27 21:25 UTC
Read the original article Hit count: 181

I'm writing my first programming language that is object orientated and so far so good with create a single 'class'. But, let's say I want to have to classes, say ClassA and ClassB. Provided these two have nothing to do with each other then all is good. However, say ClassA creates a ClassB--this poses 2 related questions:

-How would the compiler know when compiling ClassA that ClassB even exists, and, if it does, how does it know it's properties?

My thoughts thus far had been: instead of compiling each class at a time (i.e scan, parse and generate code) each "file (not really file, per se, but a "class") do I need to scan + parse each first, then generate code for all?

© Programmers or respective owner

Related posts about programming-languages

Related posts about compiler