Sather Home Page

Section 6.6.2:
Shared Definition

Defining a shared, like defining an attribute, is merely a short-hand way of defining one or two features - a reader routine and a writer routine. The way in which these are implemented in any conforming Sather implementation does not change this.

The difference between a shared entity and an attribute lies in the different internal visibility - captured in the invariants to the abstract syntax below.

Concrete Syntax

shared definition = [Private_SY | Readonly_SY], Shared_SY,
(simple value | declaration) ;

Abstract Syntax

The two features (reader and writer) which go to make up the attribute short-hand need to be defined as a pair as follows.

Reader

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.

Writer

This feature needs defining with a single statement as implementation, with a single argument, 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 (len imp = 1)
      and (hd imp = Assign_Call)
      and (val = nil)
      and (card args = 1)

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: Wednesday, 25 April 2001.
Produced with Amaya