Identifier resolution, the great implementation defined mess.

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Tue Sep 16 23:51:44 PDT 2014


So, as I implement more and more features of D, the question of 
identifier resolution pops up more and more, to the point it 
starts to become a problem.

Each feature that introduce new lookup is usually defined, but 
there is no definition of what are the priorities in between 
them, and how the should interact.

When resolving an identifier in an object, if local lookups 
fails, here are the possible fallback places where you look into:
  - parent class/interface (1)
  - alias this (1)
  - __outer (1)
  - UFCS (2)

That is for local symbols. This get even more tricky you put into 
the equation that one most likely want to register symbol from 
parent class/interface into the child scope as you wouldn't want 
an overridden method to resolve differently than a a non override 
one, but not other symbols.

Now let's consider the free symbol scenario. It can fallback in 
various ways as well:
  - this (1)
  - context (2)
  - with statement (2)
  - import (2)

And as for local symbols, fallback can recursively fallback into 
each others.

Here are the possible fallback:
  1 - parent class/interface
    - alias this
    - __outer
  2 - context
    - with statement
    - import
    - this

Sounds like we need to define some priorities here.


More information about the Digitalmars-d mailing list