aboutsummaryrefslogtreecommitdiff
path: root/docs/notes/identifier_binding.txt
blob: c5d9c664bb96037842b39081a0cdddd8e14a40ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47


Identifier binding
------------------

    namespace aaa.bbb.ccc {
        
        typedef ddd = xxx.yyy;
        
    }
    
In this example, xxx.yyy could be located in aaa.bbb.ccc, aaa.bbb, aaa
or in the root namespace.

This means that we can't bind identifiers as they are identified. I think
this could instead be solved in three phases like this:

    parsing phase:
    
        aaa.bbb.ccc.(xxx.yyy) is created, but (xxx.yyy) is marked as unbound.
        
        at a later time aaa.xxx.yyy might be defined.
    
    duplicate elimination phase:
    
        If equal identifiers occur more than once in a namespace, then all
        but one must be eliminated. This can be done as follows:
        
            1. sort the identifiers: identifiers with strictly more public
               types are places first.
            
            2. if there are identifers that can't be compared (for example,
               if their types are incompatible), then report an error.
            
            3. eliminate all but the last identifier.
            
    
    binding phase:

        all unbound identifiers are processed as follows:
        
            1. we check if the identifier exists the current namespace
            
            2. if not found, we look in parent namespaces, including the root.
            
            3. if still not found, we report an error