General question about compiling / linking

As many of you might know, I have a weird obsession with writing scripting languages entirely in Xojo (see ObjoScript and Roo).

I have a technical question about language implementation that I’m hoping someone on this forum is smart enough to help me out with.

How does a language like Xojo handle compiling classes in the correct order? For example, in my scripting language say I have these two classes:

class Person {
  occuptaion As Job

class Job {}

This will work if Job is defined before Person but not the other way around. How does a language like Xojo handle this because presumably when it assembles your project it needs to figure out the same problem. In some of my Xojo projects I have hundreds of classes in the navigator and yet Xojo’s autocomplete and compiler assemble things correctly. Do you think the IDE does some clever semantic analysis before assembling the classes in the correct order?

I’d like to add static typing to my scripting language but unless I can figure out an approach to this I will struggle to get it working.

1 Like

I would imagine it is some kind of structure.

Using your example it could be something like:
1.Class Person is found so it is added to the structure with a reference to where it is.
2.Class Person is parsed and identifies Job. It checks the structure and finds no entry so it adds it to the structure with a null reference.
3.Class Job is found. It checks the structure and updates the Job entry with the reference to where it is.

1 Like

You could try a two-pass method, building a symbol table in pass one.


The C approach was to have a header file with the definitions, separate from the code.

Yeah I think that’s the solution. I probably need another step after parsing but before compilation to sort the issue out. Hmm, annoying as that will require some major refactoring…

@GarryPettet - this might give you some hints:


That’s a great link. Hadn’t heard of that site but it’s got lots of cool content.