Anvil | Smiths Smiths | Register Register | Login Login |
Search:
Show links Show tools Show tree | Previous document Next document | njet.org > Anvil > Documentation > Language reference > Statements > Definition statements > Classes

Class

The Class definition declares a class type. Classes can contain imports, constants, variables, member variables, functions, methods, and other classes (called inner classes). A function with the same name as a class (if any) is called a constructor. A constructor is called when a new instance of a class is created using a new operator.

Inside a class an ordinary function or variable definition declares a method and a member variables. However when prefix with ``static´´ they declare function and variable instead. Body of function or variable initialization is a static region, from which no instance bound entities may be referred.

Class may extend one other class, referred to with a dotted name. xxx.

Class may implement one or more interfaces, referred to with dotted names. xxx.

Some class methods have a special meaning. See Class customization.

  entity := ( "module" "." symbol | symbol ) ( "." symbol ) * 
  class  :=  
    "class" symbolname  
    [ "extends" entityclass ]  
    [ "implements" entityinterface ( "," entityinterface )* ] 
    "{"  
      ( import 
      | constant  
      | variable  
      | function  
      | "static" variable  
      | "static" function  
      | class  
      )*  
    "}" 
See also  | Import  | Definition statements  | Modules  | Grammar  | Namespaces  | <class>
Contributes notes:
Add a note
What's new | Anvil