[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP Pascal for OpenVMS
Language Reference Manual


Previous Contents Index

10.2.16 FLOAT

The FLOAT attribute selects the default format for REAL and DOUBLE data types. The FLOAT attribute has the following format:


[FLOAT(keyword)]
You can specify the following keywords for this attribute:
  • D_FLOAT yields REAL=F_FLOATING, DOUBLE=D_FLOATING
  • G_FLOAT yields REAL=F_FLOATING, DOUBLE=G_FLOATING
  • IEEE_FLOAT yields REAL=S_FLOATING, DOUBLE=T_FLOATING

For More Information:

10.2.17 GLOBAL

The GLOBAL attribute provides a strong definition of a variable or routine so that other independently compiled units can refer to it.


                       {identifier        }
         [ GLOBAL [[ ( {'string-literal'  } ) ]] ]
                       {                  }

identifier

Identifier passed to the linker. It is passed in uppercase. If you omit the identifier, the name of the variable is used as the name of the common block.

string-literal

Literal passed, unmodified, to the linker.

Usage and Default Information:

  • You can apply the GLOBAL attribute to variables, routines, and compilation units. When used on a MODULE, the GLOBAL attribute changes the name of the compiler-generated TO BEGIN DO section if present.
  • Global and external variables are implicitly static. Thus, they conflict with the AUTOMATIC attribute.
  • By default, global and external routines have the characteristics of unbound routines.
  • You cannot apply the GLOBAL attribute to variables of nonstatic types.

For More Information:

  • On default visibility attribute information ( Section 10.2.25)
  • On an example of GLOBAL and on the EXTERNAL attribute ( Section 10.2.15)
  • On compiling and linking (HP Pascal for OpenVMS User Manual)

10.2.18 HIDDEN

The HIDDEN attribute prevents information concerning a constant definition or a type, variable, procedure, or function declaration from being included in a generated environment file. You can only use the HIDDEN attribute on objects at the outermost level of the compilation unit.

It is possible to prevent all declarations within a declaration section from being included in the environment file by preceding the reserved word CONST, TYPE, or VAR with the HIDDEN attribute.

For More Information:

10.2.19 IDENT

You can use the IDENT attribute to qualify the name of a compilation unit. In the absence of an IDENT attribute, the string '01' is supplied to the linker.


IDENT( name-string )

The name-string can contain additional information whose use is implementation specific. The HP Pascal compiler uses this string to supply identification information to the linker.

Consider the following example:



[IDENT( '100.5' ),ENVIRONMENT( 'sample.pen' )] MODULE SAMPLE;

In this example, the IDENT string '100.5' is supplied to the linker.

For More Information:

  • On name-string syntax ( Section 10.1)
  • On compiling and linking (HP Pascal for OpenVMS User Manual)

10.2.20 IMMEDIATE

The IMMEDIATE attribute causes a formal parameter value in a routine declaration to be passed by immediate value. This attribute can be used on scalar and floating-point parameters that are passed by immediate value. On OpenVMS I64 and OpenVMS Alpha systems, the parameter must be 64 bits or smaller. On OpenVMS VAX systems, the parameter must be 32 bits or smaller.

Note

The IMMEDIATE attribute is not allowed on formal parameters of schema types.

For More Information:

10.2.21 INHERIT

The INHERIT attribute indicates the environment file or files to be inherited by a compilation unit. The environment files specified by the INHERIT attribute must already have been created in compilation units (by either the ENVIRONMENT attribute or a compilation switch).

The compilation unit inherits one or more environment files named by the file specifications in the name strings.


INHERIT( {name-string},... )

Usage and Default Information:

There is a default file type of .PEN for inherited environment files.

For example:


    {
      Program inherit_example.pas
    }
    [INHERIT ('share_data')]
    Program inherit_example(output);
      CONST
        My_Rate   = Rate_For_Q1*2.0;
    BEGIN
      Writeln(My_Rate)
    END.

When the preceding program is compiled, the compiler first attempts to open the file 'share_data' as an environment file. If 'share_data' is not found the compiler attempts to open 'share_data.pen' as an environment file. If 'share_data.pen' is not found an error message is issued and the compilation is stopped.

For More Information:

  • On programs and modules ( Section 7.4)
  • On compilation switches and separate compilation (HP Pascal for OpenVMS User Manual)

10.2.22 INITIALIZE

You can apply the INITIALIZE attribute to procedures to indicate that the procedure is to be called before the main program is entered. A compilation unit might include any number of INITIALIZE procedures, all of which are called in an unspecified order before the main program is entered.

Usage and Default Information:

  • In the absence of the INITIALIZE attribute, the compiler assumes that a routine can be activated only by actual calls within the program.
  • Within modules, you should use the TO BEGIN DO section instead of the INITIALIZE attribute. All TO BEGIN DO clauses are executed before INITIALIZE routines.
  • By default, INITIALIZE procedures have the characteristics of unbound routines.
  • An INITIALIZE procedure cannot have a formal parameter list.
  • An INITIALIZE procedure cannot be external.

Consider the following example:



PROGRAM Routine_Activate;

[INITIALIZE] PROCEDURE Check_Open; {Procedure body...}

{In the executable section:}
BEGIN   {HP Pascal activates Check_Open}
   {Body of program...}

In this example, the body of the INITIALIZE procedure Check_Open is executed before the main program is activated.

For More Information:

10.2.23 KEY

You can apply the KEY attribute to record fields to indicate that the field is to be used as a key field when the record is part of an indexed file.


                 {n [[, {options},... ]]  }
         KEY [[( {{options},...           } )]]
                 {                        }

n

The parameter n represents the key number. A key number of 0 indicates that the field is the primary key of the record. All other key numbers indicate alternate keys. The key number must be a constant expression that denotes an integer value in the range from 0 through 254.

options

The options parameter lets you specify certain characteristics of the record key by listing the desired options on the KEY attribute.

Table 10-4 lists the possible KEY attribute options.

Table 10-4 KEY Attribute Options
Option Action Negation
ASCENDING Specifies an ascending collating sequence DESCENDING
CHANGES Specifies that changes can be performed on the key NOCHANGES
DUPLICATES Specifies that duplicates of the key are allowed NODUPLICATES

Usage and Default Information:

  • If you omit the key number, the default value is 0.
  • By default, the primary key is ASCENDING, NOCHANGES, and NODUPLICATES. It is possible to override these defaults, with the exception of the NOCHANGES option. It is illegal to specify CHANGES on the primary key.
  • The default for an alternate key is ASCENDING, CHANGES, and DUPLICATES.
  • When you create a new indexed file with more than one key field, you cannot omit any key numbers in the range from 0 through the highest key number specified.
  • The KEY attribute is ignored except when the record is a component of a file.
  • A key field can be of any ordinal type or of type PACKED ARRAY OF CHAR. If the key field is of type PACKED ARRAY OF CHAR, its length cannot exceed 255 characters.
  • The KEY attribute does not affect type compatibility rules.
  • A key field cannot be unaligned.
  • A key field of an ordinal type must be allocated in exactly one byte, one word, one longword, or one quadword. (Key fields can be allocated in a quadword only on OpenVMS I64 and Alpha systems.)
  • An integer key field that is allocated one byte cannot have negative values.

Consider the following example:



TYPE
   Register = RECORD
       Student_No      : [KEY( 0, DESCENDING )] INTEGER;
       Student_Name    : RECORD
          Last_Name     : PACKED ARRAY[1..20] OF CHAR;
          First_Name    : PACKED ARRAY[1..15] OF CHAR;
          Initial       : CHAR;
          END;
      Course_Load      : INTEGER;
      Grade_Average    : REAL;
      Class            : [KEY( 1 )] PACKED ARRAY[1..9] OF CHAR;
      END;

This example defines the identifier Register to denote a record type. The first field, Student_No is the primary key of the record. It has been defined as a DESCENDING, NOCHANGES, and NODUPLICATES key. Register contains another field, Class, which is established as the alternate ASCENDING, CHANGES, and DUPLICATES key.

For More Information:

10.2.24 LIST

You can apply the LIST attribute to a formal parameter of a routine and indicates that the routine can be called with multiple actual parameters that correspond to the last formal parameter named in the routine heading.

You can also use the ARGUMENT and ARGUMENT_LIST_LENGTH predeclared routines when writing procedures and functions that use the LIST attribute.

Usage and Default Information:

  • In the absence of a LIST attribute, an error results if the number of actual parameters exceeds the number of formal parameters.
  • You can apply the LIST attribute only to the last formal parameter in a parameter list.
  • You can supply zero, one, or more than one actual parameter to correspond to a LIST formal parameter, but you must use positional syntax when supplying them. The number of actual parameters you can supply is limited to 255.
  • You can use the LIST attribute on the parameter list of a routine parameter, but you must use positional syntax when specifying them. Using the LIST attribute on routine parameters is allowed only on external routines.
  • You can use the LIST attribute on conformant parameters to indicate that an external routine can take an arbitrary number of arrays or VARYING OF CHAR parameters, respectively. Using the LIST attribute on conformant parameters is allowed only on external routines.
  • All actual parameters that correspond to a LIST formal parameter must be compatible or congruent with the type of the formal parameter.
  • For formal and actual parameter lists of routine parameters to be congruent, the actual routine parameter and the corresponding formal routine parameter must either both have the LIST attribute or both lack the LIST attribute. Consider the following example:


    
    PROCEDURE Foo( PROCEDURE q( x : [LIST] CHAR ) );
    
    

    This defines the routine Foo with the formal routine parameter q that defines the formal list parameter x. Consider the following example:


    
    PROCEDURE Bar( x : [LIST] CHAR );
    
    

    This defines Bar to have a formal list parameter x. Consider this call to Foo:


    
    Foo( Bar );
    
    

    This calls Foo passing the actual routine parameter Bar. The formal parameters of q and Bar contain the LIST attribute, so this is a legal call.

For example, the function Average demonstrates the use of the LIST attribute, which allows any number of like expressions to be passed to a function:



PROGRAM Use_List(OUTPUT);
   FUNCTION Average ( P: [list] INTEGER): REAL;
      VAR
        SUM: REAL VALUE 0.0;
        I: INTEGER;
      BEGIN
      FOR I:= 1 TO ARGUMENT_LIST_LENGTH(P) DO
        SUM:= SUM + ARGUMENT (P,I);
      AVERAGE:= SUM/ARGUMENT_LIST_LENGTH(P);
      END;
BEGIN
WRITELN(AVERAGE(3,6,9),AVERAGE(10,3,4,17));
END.

For More Information:

10.2.25 LOCAL

The LOCAL attribute indicates that an object is unavailable to other independently compiled units.

Usage and Default Information:

  • By default, all variables and routines are local.
  • Variables with any visibility attribute other than LOCAL are implicitly static.
  • Routines with any visibility attribute other than LOCAL cannot refer to automatic variables declared in enclosing blocks and can call only those routines that are local, predeclared, or unbound. (By default, routines declared at program or module level have the characteristics of unbound routines.)

For More Information:

10.2.26 LONG

The LONG attribute specifies the amount of storage in longwords to be received by the object.


LONG [[( n )]]

The optional constant n indicates the number of longword storage units.

Consider the following example:



PROGRAM Size;
TYPE
   Status = [LONG] BOOLEAN;
VAR
   Return_Status : Status;

FUNCTION Example( Param1, Param2 : INTEGER ) : Status; EXTERNAL;
   {Function body...}

The program Size defines a BOOLEAN type Status and declares a variable Return_Status of this type. So, the result type of the function is declared to have a size of one longword. The machine code that references the result type can not copy the entire longword, however, if the default size for a Boolean is less than a longword.

For More Information:

  • ACCURATE (Default)
  • FAST

10.2.27 NOOPTIMIZE

The NOOPTIMIZE attribute prohibits the compiler from optimizing code for the compilation unit or routine. The NOOPTIMIZE attribute can only be applied to routines on OpenVMS VAX systems.

On OpenVMS VAX systems, the NOOPTIMIZE attribute guarantees left-to-right evaluation order with full evaluation of both operands of the AND and OR Boolean operators to aid in diagnosing all potential programming errors. On OpenVMS I64 and OpenVMS Alpha systems, NOOPTIMIZE only guarantees full evaluation.

If you wish to have short circuit evaluation even with the NOOPTIMIZE attribute, then use the AND_THEN and OR_ELSE Boolean operators.

For More Information:

10.2.28 OCTA

The OCTA attribute specifies the amount of storage in octawords to be received by the object.


OCTA [[( n )]]

The optional constant n indicates the number of octaword storage units.

For More Information:

10.2.29 OPTIMIZE

The OPTIMIZE attribute specifies optimization options that are to be enabled during compilation of a compilation unit or routine.


OPTIMIZE [[( {identifier},... )]]

The options listed with the OPTIMIZE attribute are enabled. The negation of an option disables that optimization. The valid options are ALL, NONE, INLINE, NOINLINE. Table 10-5 lists the options.

Table 10-5 OPTIMIZE Attribute Options
Option Action
[OPTIMIZE],
[OPTIMIZE(ALL)]
Enables all optimization components. Inline expansion of user-defined routines is enabled in automatic selection mode.
[OPTIMIZE(NOINLINE)] Disables inline expansion for user-defined routines. All other optimization components are enabled or disabled according to the command line or the setting of the OPTIMIZE attribute on an enclosing scope routine.
[OPTIMIZE(INLINE)] Enables preferential inline expansion of user-defined routines. All other optimization components are enabled/disabled according to the command line on an enclosing scope routine.
[OPTIMIZE(ALL,NOINLINE)] Enables all optimization components, disables inline expansion for user-defined routines.
[OPTIMIZE(NONE,INLINE)] Disables all optimization components, enables inline expansion of user-defined routines.
[NOOPTIMIZE],[OPTIMIZE(NONE)] Disables all optimization components, disables inline expansion of user-defined routines.

Usage and Default Information:

  • This attribute can be applied to routines and compilation units.
  • Optimization features specified with the OPTIMIZE attribute override command-line settings and settings inherited from outer scopes.
  • The INLINE option specifies that a routine should be inlined preferentially, regardless of the results of heuristics that are normally used to automatically determine if a routine is to be inlined. There are cases where a routine that is marked as INLINE preferred will not be inline expanded, such as routines that have formal parameters of nonstatic types, or that declare or access nonstatic types.
  • If no OPTIMIZE attribute is specified for a routine in a nested scope, the OPTIMIZE attribute settings from the enclosing routine are used.

Usage and Default Information on OpenVMS I64 and OpenVMS Alpha systems only:

  • If the OPTIMIZE attribute is used on a routine on OpenVMS I64 or OpenVMS Alpha systems, only the INLINE and NOINLINE keywords are processed. The other forms of the OPTIMIZE attribute are parsed, but perform no function. You cannot modifiy the optimization settings of individual routines on these systems.

Usage and Default Information on OpenVMS VAX systems only:

  • On OpenVMS VAX systems, if an explicit OPTIMIZE(INLINE) attribute exists on a routine declaration, the compiler checks for anything that prohibits inline expansion of the routine, such as it being an external routine. However, the compiler does not check the call environment, such as the size of the calling and called routine. Instead, if it is legal to expand the routine, it always expands the code regardless of the call environment. This gives you more control over the decision to inline a routine.
  • On OpenVMS VAX systems, HP Pascal does not inline routines that have formal parameters of nonstatic types, or that declare or access objects of nonstatic types.

For More Information:

  • On the NOOPTIMIZE attribute ( Section 10.2.27)
  • On the rules for routine inlining (HP Pascal for OpenVMS User Manual)


Previous Next Contents Index