• Aucun résultat trouvé

DECLARE MATRIX (*,*);

FIXED I FLOAT Rules:

2. DECLARE MATRIX (*,*);

MATRIX is a two-dimensional array.

The bounds are to be taken from a previous allocation for MATRIX or are to be subsequently specified in an ALLOCATE statement.

THE SECONDARY AT'rRIBUTE Function:

The SECONDARY attribute is used to spec-ify that certain data normally does not require efficient storage.

General format:

SECONDARY Rules:

1. This attribute may be declared only for major structures, arrays, and variables not contained in structures or arrays, i.e., for variables at level 1.

2. The attribute specifies that where possible and necessary, less than nor-mally efficient storage may be allo-cated to the variable.

THE ABNOR:MAL AND NORMAL ATTRIBUTES Function:

The ABNORMAL and NORMAL attributes are used to specify procedures and/or data as being either normal or abnormal.

General format:

ABNO:RMALINOHMAL

Rules for abnormality of procedures:

1. Abnormality is a property of both external and internal procedures.

Blocks invoking procedures that are abnormal must be within the scope of an ABNORMAL, USES, or SETS declaration for the invoked entry name. However, the invocation of an abnormal dure does not make the envoking proce-dure itself abnormal. These attri-butes enable program optimization to be performed.

2. An external procedure is abnormal if i t or any procedures invoked by it:

a. Access, modify, allocate or free external data.

b. Modify, allocate, or free their arguments.

c. Return inconsistent function values for the same argument values.

d. Maintain any kind of history.

e. Perform input/output operations.

f. Return control from the procedure by means of a GO TO statement.

3. An internal procedure is abnormal:

a. Under any of the conditions listed above for external procedures.

b. If i t , or any procedures called by i t , access, modify, allocate, or free variables declared in an outer block.

4. Abnormal external procedures invoked as functions must be declared with at least one of the attributes, ABNORMAL, USES, or SETS. The scope of this declaration must include the invoking block.

5. ABNORMAL used alone specifies that all possible types of abnormality should be assumed. It is unnecessary to specify ABNORMAL for the built-in functions, TIME and DATE.

6. The NORMAL attribute specifies that the entry name is for a procedure that is not abnormal.

Rules for abnormal data:

1. The ABNORMAL attribute may be declared for any variable.

2. The ABNORMAL attribute specifies that a variable may be altered or otherwise accessed at an unpredictable time dur-ing the execution of a program. This situation might occur, for example, during the execution of an ON-unit as described in liThe ON Statement," in Chapter 8.

3. Every time ABNORMAL data is referred to, its associated storage contains its current value.

Default for abnormality of procedures:

If an external entry name appears only as a function reference, the entry name is

assumed to have the ABNORMAL attribute.

Default for abnormality of data:

Variables are assumed to be NORMAL, except structures containing ABNORMAI., ele-ments; such structures may not be declared declaration and the invoked proce-dure. data designated by explicit argu-ments in the case of a CALL state-ment.

4. The USES and SETS attributes may be declared for any entry name used to invoke a procedure. The scope of this declaration must include the invoking block. If the ENTRY attribute is not declared, ENTRY is implied. If either USES or SETS is declared in the invok-ing procedure, complete information must be given about the data that is otherwise abnormal, the ABNORMAL attribute should not be specified.

ENTRY NAME ATTRIBUTES

An identifier may be declared to be an

The data attributes specify the charac-teristics of the value returned when the entry name is invoked as a function. If

data attributes are not specified, default or implicit characteristics will be assumed (see "Assignment of Attributes to Identifiers" in this chapte~

An explicit declaration of an internal entry name and the procedure block having the entry name must both be internal to the same block.

The ENTRY Attribute Function:

The ENTRY attribute is used to declare, wi thin a lprocedure, entry names that are referred to in that procedure.

General format:

ENTRY [ (parameter-attribute-list [,parameter-attribute-list] ••• )]

Rules:

1. When ENTRY is used6 i t specifies that the identifier being declared is an entry name.. An entry name must be declared with the ENTRY attribute unless the entry label is known in the same block, or unless a reference is made to the entry name in a CALL

statement or in a function reference with arguments, or if i t is declared to have any of the attributes SETS, USES, GENEHIC, and BUILTIN. INTERNAL entries may only be declared in the block to which the procedure is inter-nal. ENTRY without a parameter attri-bute list specifies nothing about the number or nature of the parameters.

2. When ENTRY is used with parameter attribute lists, each parameter bute list is a succession o£ attri-butes describing the parameters of the entry point.. Permitted attributes are thosle allowed for parameters.

3. The number of parameter attribute lists must be the same as the number of parameters required by the entry point. If a parameter attribute list is null, its place must be kept by a comma.

4. Parameter attribute lists are not nec-essa:ry if the parameters of the entry name are not to be described.

5. The dimension attribute may be speci-fied for array parameters. It must be the first attribute specified £or the parameter.

6. The structuring for a structure param-eter is specified by a structure des-crip·tion using level numbers wi thout identifiers i' the level number being immediately followed by the list of

attributes for that level of the structure. The first item in the description of the structure parameter must be at level one.

7. Expressions occurring in ENTRY attri-butes for length or dimension bounds are evaluated upon entering the block to which the declaration of the ENTRY attribute is internal. If an argument position sRecifies an entry with no data attributes, no default data attributes are provided.

Default:

If no attributes or level numbers are given for a parameter, no assumptions are made about it. When any attributes are specified, the remaining required attri-butes are deduced according to the default rules given in "Assignment of Attributes to Identifiers."

The GENERIC Attribute Function:

The GENERIC attribute is used to define a name as a family of entry names, each of which is referred to by the name being declared. When the generic name is referred to, the proper entry name is selected, based upon the arguments speci-fied for the generic name in the procedure reference.

General format:

GENERIC (entry-name-declaration [,entry-name-declaration] ••• ) Rules:

1. No other attributes may be specified for the name being given the GENERIC attribute.

2. Each "entry name declaration" follow-ing the GENERIC attribute corresponds to one member of the family.

3. Each entry name declaration must have the ENTRY attribute. It may optional-ly have ABNORMAL, NORMAL, USES, SETS, BUILTIN, and data attributes. No entry name declaration may have the GENERIC attribute.

4. Each entry name declaration must spec-ify attributes or level numbers for every parameter of the associated entry name. Attributes unspecified but required for full definition will be deduced from default rules.

5. When a generic name is referred to, the attributes of the arguments must match exactly the list following the entry name declaration of one and only

one member of the family. The ref-erence is then interpreted as a ref-erence to that member. Thus, the selection of a particular entry name is based upon the arguments of the reference to the generic name.

6. The selection of a particular entry name is first based on the number of arguments in the reference to the name. The following attributes are then considered in choice of generic members:

Base Scale Mode Precision PICTURE

LABEL (but not range list) Dimensionality (but not bounds) CHARACTER (but not length)

"BIT (but not length) VARYING

TASK EVENT

ENTRY (but not parameter descrip-tion or other attributes of entry names other than data attributes of the value returned by a function)

FILE (but no other FILE attributes) structuring, including only the

attributes listed above for the structure members.

7. Generic entry names (as opposed to references) may be specified as argu-ments to non-generic procedures if the invoked entry name is declared with the ENTRY attribute (explicit or implicit for internal procedures).

This ENTRY attribute must specify that the appropriate parameter is an entry name and specify by means of a further ENTRY attribute the attributes of all its parameters. This enables a choice to be made of which family member is to be passed.

Example:

DECLARE

CALCULATE GENERIC (FIXCALC ENTRY (FIXED), FLTCALC ENTRY (FLOAT», Y FLOAT

INITIAL (50);

X=Y + CALCULATE (~;

The assignment statement results in the invocation of the procedure FLTCALC, since the argument Y matches the entry attribute of the FLTCALC member of the family.

The BUILTIN Attribute Function:

The BUILTIN attribute specifies that the reference to the associated identifier within the scope of the declaration is interpreted as a reference to the built-in function or pseudo-variable of the same name.

General format:

BUILTIN Rules:

1. BUILTIN is used to refer to a built-in function or pseudo-variable in a block that is contained in another block in which this name has been declared to have another use.

2. If the BUILTIN attribute is declared for an entry name, i t may have no other attributes.

3. For a list of built-in functions see Appendix 1.

SCOPE ATTRIBUTES Function:

The scope attributes are used to specify the scopes in which declared identifiers are known.

General format:

{INTERN. AL }

EXTERNAL [(identifier)]

Rules:

1. For a full discussion of the INTERNAL and EXTERNAL attributes, see "Scope of Declarations".

2. In the form EXTERNAL (identifier), the identifier specifies a heading for the declared name. The scope of the name is then the union of the scopes of all EXTERNAL declarations of the same name with the same heading.

Default:

If the scope is unspecified for variable names, INTERNAL is assumed.

Example:

DECLARE SUM EXTERNAL (~;

The variable SUM with the heading X.

is declared external In other declarations,

tbe beading distinguishes from other variables named heading or other headings.

STORAGE CLASS AT'rRIBUTES Function:

this SUM

variable with no

Storage class attributes allocate a particular class of program execution bas been completed.

2. AUTOlMATIC specifies that storage is allocated on each entry to the block to which the storage declaration is internal. The storage is released on leaving th(~ block. . If the block is a proc1edure that is invoked recursively, the previously allocated storage is

"pushed down" on entry, and the latest

3. CONTlROLLED specifies that full control will be maintained over the allocation and freeing of storage by means of the

stab:~ments l\LLOCATE and FREE.

4. AUTOMATIC variables may have INTERNAL

7. Variables declared with adjustable leng1ths and dimensions ma:y not have

·the STATIC attribute.

8. If a procedure involving static AUTOMATIC is assumed.

EXAMPLE: PROCEDURE; within data aggregates.

General format: numerlC field elements that surround i t . There should be no unused storage between two adjacent elements,