Sather Home Page

Section 6.6.6:
Include Clause

Code inclusion in Sather is completely independent of class behaviour inheritance (sub-typing and/or super-typing). It is a mechanism by which an implementation class (or partial class) may

  1. Make use of code written in other implementation (or partial) classes syntactically. Where the included class has generic arguments these are substituted by the arguments provided in the inclusion specification as a form of macro expansion.
  2. Make use of a non-global class library.

Concrete Syntax

include clause = [Private_SY], Include_SY,
(library include | class include),
[feature modifier list] ;
library include = Library_SY, identifier ;
class include = type specifier ;
feature modifier list = feature modifier,
{Comma_SY, feature modifier} ;
feature modifier = (identifier | iter name), Rename_SY,
[Private_SY | Readonly_SY],
[(identifier | iter name)] ;

The inclusion facility provided in accordance with this concrete syntax, whether of a non-global library or some partial class, is primarily concerned with modification of name-space visibility and name substitution. The results of this may be seen as source text transformation and, therefore, have no separate corresponding abstract syntax, static or dynamic semantics. There are instead four different required concrete syntax manipulations :-

  1. Making names visible
    Where a library class is being defined, then all classes within that library name-space will be visible without the need for an inclusion clause, although the presence of such a clause is not forbidden.
  2. Argument substitution
    Where an included (partial) class has class arguments, the arguments used in the inclusion clause type specification shall be subject to macro substitution for their formal argument equivalents by inclusion. The code included shall therefore appear as though the arguments given to the inclusion type specification were those in the source text of the class being included.
  3. Feature renaming
  4. Visibility modification

If a class including some named feature redefines that feature, it overrides all conflicting methods from included classes. Reader and writer routines may be redefined, however, there must be no type conflict between the redefined methods and those included.

WARNING The inclusion of classes or libraries may make significant changes to the type graph and compatibility rule application in the including class. There are no exceptions to the correctness of definition/uses type compatibility or type graph consistency caused by inclusion of any kind. Remember this is only a concrete syntax manipulation.

Specification Index Language Index Section 6 Index
Comments or enquiries should be made to Keith Hopper.
Page last modified: Monday, 29 May 2000.
Produced with Amaya