Changing the variable search order

Tagged:  •  

GST, and Smalltalk in general, has many more places in which to search for variables than most programming systems. Besides instance variables, in-class and inherited, the compiler has to search a number of pools:

  • All inherited namespaces and their superspaces
  • All inherited class pools
  • All inherited shared pools

Traditionally, GST's search order has been somewhat idiosyncratic. This isn't a problem, of course, until you start making name clashes.

So I've designed a new pool search order, and implemented it for the STInST compiler:

  1. Given a class, starting with the method-owning class:
  2. Search the class pool.
  3. Search this class's shared pools, combined using something like a topological sort, left-to-right, removing any resulting pools that are any of this class's namespace or superspaces.
  4. Search this class's namespace and each superspace in turn before first encounter of a namespace that contains, directly or indirectly, the superclass. This means that if the superclass is in the same namespace or a subspace, no namespaces are searched.
  5. Move to the superclass, and repeat from #2.

I've made this available, including SUnit tests, from my pool-resolution branch; see PoolResolution for more details, discussion, and the git archive's location.

I made my comments in issue 206.

User login