# Section 6.6.1:
Constant Definition

Defining a constant in a class is like defining a shared entity, except that it has only a reader routine feature! This means that all objects of the class share the same value - but that it is read only for every object of any class.

#### Concrete Syntax

constant definition = | [Private_SY], Constant_SY,
| (simple value | enumerated constants) ;

simple value = identifier, return signature, initialise ;

enumerated constants = | identifier, [initialise],
| [Comma_SY,identifier list] ;

initialise = assign op, expression ;

#### Abstract Syntax

This feature needs defining without an implementation, without arguments - just a value, giving the invariant shown below.

Feature ::
name : token
args : [ set of Feature ]
kind : [ Type_Specifier ]
value : [ Expression ]
impl : [ seq of Statement ]
vis : [ Visibility ]
ext_vis : Visibility
uses : [ Method_Kind ] ;
inv mk_Feature(-,args,-,val,imp,vis,-,use) ==
use = One_Shot
and (vis = {Use})
and (imp = nil)
and (val <> nil)
and (args = nil)

Note that the external visibility field needs testing against the concrete syntax specifications in the well-formedness checks.

#### Static Semantics

TO BE DONE

#### Dynamic Semantics

TO BE DONE

| Specification Index |  | Language Index |  | Section 6 Index

Comments or enquiries should be made to Keith Hopper. Page last modified: Friday, 26 May 2000. |