next up previous contents
Next: Interfaces Up: Shore Data Language Reference Previous: Linking

 

Name Scopes

The body of a module, interface, struct, or union declaration is a name scope. Each scope contains a sequence of definitions, each of which defines one or more names and binds each of them to a constant, type, interface, attribute, or operation. Names defined in a scope must be distinct. Each scope also has a name. Name N defined in scope S can be referred to unambiguously with the scoped_name S::N. Since scopes nest, this construction may be iterated. For example, S::T::N refers to the name N defined in scope T, which was defined in scope S. In this document, ``name'' means unqualified name (one with no ``::'' ) unless specified otherwise. A use of an unqualified name N refers to the definition of N in the smallest scope enclosing the use that defines N (but see also the discussion of inheritance in the next section).

The import clause of a module and the inheritance clause of an interface effectively merge the sets of scoped names defined in two or more scopes. Names defined in more than one of these scopes must be qualified to prevent ambiguity.  

Examples

    module m1 { 
        export all;    
        const long C = 1;    
    } 
    module m2 { 
        import "m1"; 
        const long D = C; // error: ambiguous (m1::C or m2::C) 
        const long C = 2; 
        const long E = m1::C; // ok: E = 1  
    }



Marvin Solomon
Fri Aug 2 13:39:38 CDT 1996