Unification

If you are making a language that uses type unification, the TypeHolder class may or may not be of some use. The idea is that a type holder can be empty (the type it holds is still unknown) and it can be unified with other type holders.

If it is unified with another type holder that is empty, then they are linked together. If either one of them is then unified with a type holder that contains a type, then they all will contain that type.

If two type holders are unified that both contain a type, it calls a unify method on one of the contained types to unify it with the other (which may just mean that it checks to make sure they are the same type, but could also be more complex than that).