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 > Constants

Constants

Declares constant into enclosing script, class or interface. Constants cannot be re-assigned after initialization although the value itself can be changed provided that it is mutable.

If expression used in initialization evaluates to constant value at compile time it is called static initializer, otherwise it is called non-static initializer. Typically expression involving only operations between literals evaluates to constants.

Non-static initializer of constants (and variables) are placed into hidden initialization function in order of declaration, depth first when descending into classes and interfaces. Therefore it is important to mainitin that order of declaration such that referred entity is declared before referrer. Entities referred before initialization contains ``undefined´´.

  constant      := "const" constant-decl ( "," constant-decl )* ";" 
  constant-decl := symbolname "=" exprinitializer 
See also  | Definition statements  | Classes  | Interfaces  | Modules  | <const>  | Grammar  | Namespaces
Contributes notes:
Add a note
What's new | Anvil