AngelScript
Namespaces

Namespaces can be used to organize large projects in logical units that may be easier to remember. When using namespaces it is also not necessary to worry about using names for entities that may exist in a different part of the project under a different namespace.

  namespace A
  {
    // Entities in a namespace see each other normally.
    void function() { variable++; }
    int variable;
  }
  namespace B
  {
    // Entities in different namespaces don't immediately see each other and 
    // can reuse the same name without causing name conflicts. By using the 
    // scoping operator the entity from the desired namespace can be explicitly
    // informed.
    void function() { A::function(); }
  }

Observe that in order to refer to an entity from a different namespace the scoping operator must be used, even if the other namespace is a parent namespace or even the global scope.

  int varInGlobalScope;
  namespace Parent
  {
    int varInParentScope;
    namespace Child
    {
      int varInChildScope;
      void func()
      {
        // Accessing variable in parent namespace requires 
        // specifying the scope
        varInChildScope = Parent::varInParentScope;
        // To access variables in global scope the scoping 
        // operator without any name should be used
        Parent::varInParentScope = ::∅varInGlobalScope;
      }
    }
  }
  void func()
  {
    // Access variable in a nested namespace requires 
    // fully qualified scope specifier
    int var = Parent::Child::varInChildScope;
  }