Overlay Declarations

Overlaying may be found desirable when COMMON data is required in some segments and not in others, as it enables global data space to be re-used for other purposes. However, indiscriminate use of overlaying should be avoided, as it can lead to confusion and obscurity. The facility causes apparently different data references to refer simultaneously to the same objects of data, i.e. as alternative names for the same storage locations. To form an overlay declaration, an ordinary data declaration is preceded by a phrase of the form


          OVERLAY
          Base
          WITH
        

where Base is a data reference which has previously been covered by a declaration in the same COMMON communicator or in the same segment. The base may be a simple reference, on-dimensional array reference or a table reference treated as a one-dimensional array of whole words. If the array or table identifier is not indexed, it refers to the location of its zero'th element (which may be conceptual). Storage allocated by the overlay declaration starts from the base, proceeds serially (as in ) and will not be overlaid by succeeding declarations unless these are themselves overlay declarations. The syntax of an overlay declaration is


        Overlaydec ::= 
    OVERLAY
        Base
        WITH
        Datadec
      


        Base ::= 
    ( Id )
    Id [ Signedinteger  ]