Resolving Symbols

When we see a reference to symbol x in a program, our brain unconsciously looks for the closest definition. In other words, our brain tries to resolve (identify) which program entity it refers to. If we’ve only got one scope, resolving a symbol is easy. Either we find that symbol in that scope’s Symbol dictionary, or we don’t. In code, that looks like this:

 
myOnlyScope.resolve(«symbol-name»);

Method resolve does nothing more than look up symbol-name in the scope’s dictionary.

When there is more than one scope, though, resolving a symbol depends on the location of the symbol reference. In other words, the same symbol could refer to two different program entities depending on where the symbol appears in the source code. References ...

Get Language Implementation Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.