Download "user manual"
Transcript
ALGOL STATEMENTS CONTINUE STATEMENT The Continue statement IS valid In only those contexts valid for the DONE statement (see page 17); the “Loop Block” IS determined in the same way (i.e. implicitly or by specifying a block name). All loops out to the Loop Block are terminated as If DONE had been requested. C o n t r o l IS t r a n s f e r r e d t o a pornt i n s i d e t h e l o o p contalnlng the Loop Block, but after all statements in the loop. Example: FOR I-i STEP 1 UNTIL N DO BEGIN I I * CONTINUE; END ”’ is semantlcally equivalent to: FOR I-1 STEP 1 UNTIL N DO BEGIN LABEL CONT; &TO CONT; ,., CONT: END -_ PEOCEDURE STATEMENTS A Procedure statement is used to invoke the execution of a Procedure (see page 7). After execution of the Procedure, control returns to the statement Immediately followtng the Procedure statement. SAIL does allow you to use typed Procedures as procedure statements. The value returned from the Procedure is simply &carded. The actual parameters supplied to a Procedure must in tnatch t h e f o r m a l p a r a m e t e r s d e s c r i b e d i n t h e procedure declaration, modulo Sail type conversion. Thus one may supply an integer expression to a real formal, and type conversion will be performed as on page 21 If an actual parameter is passed by VALUE, only the value of the expression is given to the Procedure. This value may be changed or examined by the Procedure, but this will in no way affect any of the variables used to evaluate the actual parameters. Any algebraic expression may be passed by value. Neither Arrays nor Procedures may be passed by value (use ARRBLT, page 43, to copy arrays). See the default declarations for parameters in page 8. If an actual parameter is passed by REFERENCE, its address IS passed to the Procedure. All accesses to the value of the parameter made by the Procedure are made IndIrectly through this address. Therefore any change the Procedure makes in a reference parameter WIII change the value of the variable which was used as an actual parameter. This is sometimes useful. However If it IS not Intended, use of this feature can 18 SAIL USER MANUAL also be sotnewhat confusing as well as moderately IneffIcient. Reference parameters should be used only where needed. Variables, constants, Procedures, Arrays, and most expresslons may be passed by reference.No String expressions (or String constants) may be reference parameters. If an expression is passed by reference, its value is first placed in a temporary location; a constant passed by reference is stored in a unique location. The address of this location is passed to the Procedure. Therefore, any values changed by the Procedure via reference parameters of this form will be inaccesible to the user after the Procedure call. If the called program is an assembly language routine which saves the parameter address, it is dangerous to pass expresslons to it, since this address will be used by the compiler for other temporary purposes. A warning message will be printed when expressions are called by reference. The type of each actual parameter passed by reference must match that of its corresponding formal parameter, modulo Sail type conversion. The exception is reference string formals, which must have string variables (of string array elements) actual passed to If an algebraic type mismatch occurs the them. compiler will create a temporary variable containing the converted value and pass the address of this temporary as the parameter. A warning message will be printed. An exception is made for Fortran calls ( s e e p a g e 19). PROCEDURES AS ACTUAL PARAMENTERS If an actual parameter to a Procedure PC is the name of a Procedure PR with no arguments, one of three things might happen: 1) If the corresponding formal parameter requires a value of a type matching that of PR (in the loose sense given above in page 18), the Procedure is evaluated and its value is sent to the Procedure PC. If the formal parameter of PC requires a reference Procedure of identical type, the address of PR is passed to PC as the actual parameter. If the formal parameter requires a reference variable, the Procedure is evaluated, Its result stored, and its address passed (as with expressions in the previous paragraph) as the parameter. If a Procedure name followed by actual parameters appears as an actual parameter it is evaluated (see functions, page 24). Then if the corresponding formal