1 Pascal-6000 Release 4 Upgrade Guide =================================== Edited by Jim Miner Dave Bianchi Academic Computing Services and Systems | University of Minnesota Version 4.1 | May, 1986 | Differences from Version 4.0 are indicated by change bars in the right | margin. An asterisk indicates deleted text. | _________ +COPYRIGHT Portions of Pascal-6000 Release 4 are copyright by the University of Minnesota. It is not to be sold or distributed without the express written permission of the University of Minnesota, Academic Computing Services and | Systems. All names and references are to be left intact. The | machine-retrievable documention on the release tape is under a limited copyright. That is, you are free to copy and distribute the writeups within your organization providing that it is not done for profit and that 1 all names and references are left intact. 1 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 Table of Contents ================= page section 1 Introduction 1 Acknowledgements 2 1. Changes in Access and Use 2 1.1. PASCAL Control Statement 2 1.2. Memory Management 2 1.3. Compiler Options 2 1.3.1. Options Changed or Removed 3 1.3.2. Options Added 4 1.4. Miscellaneous 5 2. Language Changes 5 2.1. Simple Changes 6 2.2. Conformant Array Parameters 9 2.3. For Statements 11 2.4. Assignments to Functions 12 2.5. Labels and Goto Statements 13 2.6. Pack and Unpack 13 2.7. Page 13 2.8. Parameter-List Congruity 15 2.9. Textfile Input and Output 16 2.10. Record Types 17 2.11. Scope Rules 18 2.12. Lexical Symbols 20 3. Library Changes 20 3.1. Packages Changed or Removed 20 3.2. Packages Added 21 4. Internal Changes 1 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 ____________ +INTRODUCTION This guide surveys the changes made to Pascal-6000 in creating Release 4. It should aid programmers in adapting programs that run under Release 3 to run under Release 4. The guide is divided into four major sections that discuss, in order, changes in the control statement, compiler options, memory management, etc.; changes in the language supported by Pascal-6000, including extensions, restrictions, and changes; changes in the "extended" library; and internal changes. While we have attempted to insure that all significant changes are described in this guide, we cannot guarantee that it is complete. We have not listed error corrections, optimizations or other "invisible" changes. _______________ +ACKNOWLEDGMENTS The material in this manual was written by Dave Bianchi, Larry Daasch, Dan | Germann, Andy Mickel, and Jim Miner. 1 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 _________________________ +1. CHANGES IN ACCESS AND USE ________________________ +1.1. PASCAL CONTROL STATEMENT Release 4 adapts the standard CDC control statement format. The new control statement format is PASCAL(I=sfn,L=lfn,B=bfn,E=efn,REW=rs,GO,PD=d,PS=n,PL=x,DS=ds/opts) | See the chapter ACCESS of the Pascal-6000 writeup for a complete description of the control-statement parameters. The new DS parameter allows you to enforce a particular "standard" dialect | during compilation of your Pascal program. See the chapters ACCESS and | DIALECT of the Pascal-6000 writeup for a description of the DS parameter. | _________________ +1.2. MEMORY MANAGEMENT RFL control statements are no longer necessary or useful when compiling or running Pascal programs. Memory is automatically obtained from the operating system as needed. For details, see chapters MEMORY and OPTIONS in the Pascal-6000 writeup. Release 4 has an interface to Common Memory Manager. Please see chapter | CMM in the Pascal-6000 writeup for details. | ________________ +1.3. COMPILER OPTIONS There are several new compiler options in Release 4, and other options have been changed or removed. This section briefly mentions the differences from Release 3. More complete descriptions are available in the OPTIONS chapter of the Pascal-6000 writeup. __________________________ +1.3.1. OPTIONS CHANGED OR REMOVED The G, R, and W options no longer exist. G has been replaced by the GO parameter on the control-statement. R and W have been replaced by the (numerous) memory-management options. The L option has changed. The form Ln, where n is an integer, is no longer accepted and is replaced by the PD and PS parameters on the control statement. Also, the L parameter on the control statement can be used to turn off the listing (L=0). See the ACCESS chapter of the Pascal-6000 writeup for more details. 2 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 _____________ +1.3.2. OPTIONS ADDED Many options have been added, as follows. - The D Compiler Option - Diagnostics Language Option The D option selects the language in which to print syntax error messages. The format for the D option is: (*$D'ENGLISH' PRINT ENGLISH ERROR MESSAGES *) The supported languages are ENGLISH, FRENCH, and GERMAN. Any identifier other than these three sets the language to ENGLISH and causes a compiler warning message. Default is D'ENGLISH'. - The LT Compiler Option - Reset Listing Title The LT option makes it possible to change the main title in the compiler listing. - The M Compiler Options - Control Memory-Management Parameters Several new compiler options have been added to Release 4 that allow you to control the way memory is allocated to your programs. These options specify parameters used by the Pascal-6000 Memory Manager (PMM) and by the call-return mechanism. Nine new options control these parameters, and these options differ from most other compiler options in that they are specified by two-character names. The new options are MB, MD, MF, MI, MR, MS, MV, MX, and MZ. - The O Compiler Option - Options-Allowed Switch A new compiler option, O, has been implemented to switch on (O+) and off (O-) the processing of all compiler options specified in the source text of a program (options on the control statement are always allowed). The effect of O- starts after the group of compiler options that contains the O-. Once O- has been set, O+ cannot have an effect. Default is O+. - The PL Compiler Option - Set OUTPUT Line Limit The PL option serves the same purpose as the PL control statement parameter -- to set the line limit for the program parameter OUTPUT of the program being compiled. The default line limit is 2000 lines, or the setting of the PL control statement parameter. Setting PL to zero gives an infinite line limit. - The Q Compiler Option - Generate Quick Code This option controls compiler optimization of object code. Q+ means the compiler should generate "quick" code at the expense of code or data space; Q- means the compiler should reduce space at the expense of 3 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 speed. The Q option can be used to increase the speed of frequently executed procedures and to decrease the size of infrequently executed procedures. Default is Q-. - The S Compiler Option - Standard-Only Switch A new compiler option, S+, has been implemented to issue clear and unambiguous, nonfatal, warning messages indicating the use of nonstandard Pascal-6000 extensions. Extensions whose use cannot be detected except by executing the program are not controlled by the S option. For convenience, S may be switched on (S+) or off (S-) anywhere in a Pascal program with well-defined results in all cases. Default is S-. - The Z Compiler Option - Issue Statistics Messages The Z option controls the printing of statistics messages issued by the run-time system. The three messages currently printed are the LOAD FL, START FL message, the HIGHEST FIELD LENGTH message, and the CP SECS, MAX CM USED message. Z- inhibits the printing of these messages; Z+ means that the messages will be issued. Default is Z+. _____________ +1.4. MISCELLANEOUS - The maximum length of a source line has increased from 120 to 150 characters. - The source input file (I control-statement parameter) is never rewound if it has the local file name INPUT. Otherwise, the rewinding is | controlled by the REW= parameter. | - Loading is inhibited if there are compilation errors. - The compiler listing now starts with two lines of "carriage control". The first line is a "Q" which disables "auto-eject" near the bottom of each page; the second line is either a "S" or "T", depending on the print density (PD control-statement parameter). - The default page size and print density (PS and PD parameters) are based on installation defaults, or are obtained from the job default using the GETPAGE macro if it is available (NOS 2.2). - The Pascal-6000 control-statement processing now allows a slash (/) as the first delimiter. For example: PASCAL/L-. LGO/COMMENT. NOTE: The following PASCAL control statement format is also allowed: | | PASCAL,/L-. | 4 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 ________________ +2. LANGUAGE CHANGES Many of the changes to the langauge supported by Pascal-6000 are simple; they are summarized in section 2.1. The rest of this section describes more significant changes. ______________ +2.1. SIMPLE CHANGES - ORD(sets) is no longer allowed. When longer sets (>58 elements) are implemented in the future, ORD(sets) will no longer make sense. - Writing the value of a pointer variable to a textfile is no longer allowed. Instead, the value of a pointer variable can be converted to an integer by using an extended form of ORD: ORD(pointer). - SEGTEXT has been eliminated as a predefined type. Use SEGMENTED TEXT instead. - LINELIMIT has a been eliminated as a predefined procedure and has been replaced by the PL control-statement parameter and compiler option. - RELEASE has been changed, and the new predeclared procedures MARK and MNEW have been added, along with the new predefined type MARKER. See the chapter HEAP in the Pascal-6000 writeup. - A new function RELVALUE has been added. RELVALUE is essentially an | extended inverse of ORD. See the chapter PROCS in the Pascal-6000 | writeup for details. | - Use of the A, E, I, O, or U compiler options can change the meaning of a program and they are now flagged with a warning message. - There is no error reported when reading integers or integer parts of reals that are greater than MAXINT. - MESSAGE takes an optional second parameter indicating where the message should be placed. See the chapter MESSAGE in the Pascal-6000 writeup for details. - NEW and DISPOSE have been generalized to meet the standard. The first parameter of NEW can now be a component of a packed record or array. The first parameter of DISPOSE can now be a pointer-valued function call. - In earlier releases of Pascal-6000, an element of a packed array or a field of a packed record could be passed as an actual variable parameter if it occupied one or more words of storage. The standard, and thus Release 4, disallows passing any element of a packed structure as an actual variable parameter, regardless of whether or not the structure is physically packed. - The positioning operation performed by GETSEG(F,N) and REWRITE(F,N) have changed. When EOF(F) is true and N < 0, they skip one less segment backwards than they used to. This is because and end-of-file is treated by the operating systems as a special kind of end-of-record. Also, when 5 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 ABS(N) > 777776B, the effect is as if ABS(N) = 777777B and this effect is operating-system dependent. For example, GETSEG(F,777777B) skips to end-of-information under NOS. - Predeclared procedures GETFILE and PUTFILE and predeclared function EOI | have been added to allow processing of multi-file files. See the | chapter FILES in the Pascal-6000 writeup for details. | - The OTHERWISE clause in case statements has been generalized to apply to | the variant-part of variant record type definitions. In addition, | subrange notation may be used in case constant lists. See the chapter | CASE in the Pascal-6000 writeup for details. | - The error message "EMPTY SOURCE INPUT FILE." is now printed if the | source file is empty. | _________________ +2.2. CONFORMANT ARRAYS The "dynamic" array parameters supported by Release 3 have been replaced with the ISO standard "conformant array parameters". This section describes conformant array parameters and the extensions and restrictions present in Pascal-6000. (1) DYNAMIC is no longer a reserved word, and the predeclared functions LOW and HIGH no longer exist. (2) The Standard requires that all actual parameters corresponding to the formal parameters within a parameter section must have the same type. Therefore, all conformant-array parameters within a parameter section are now allowed to share a common conformant-array descriptor. Example: PROGRAM MAIN; TYPE VECTOR1 = ARRAY [1 .. 100] OF REAL; VECTOR2 = ARRAY [1 .. 50] OF REAL; VAR A, B : VECTOR1; C, D : VECTOR2; PROCEDURE P1(X,Y : ARRAY [LO .. HI: INTEGER] OF REAL); BEGIN (* P1 *) END; PROCEDURE P2(X : ARRAY [LO1 .. HI1: INTEGER] OF REAL; Y : ARRAY [LO2 .. HI2: INTEGER] OF REAL); BEGIN (* P2 *) END; BEGIN (* MAIN *) P1(A,B); P1(C,D); P2(A,C); P2(B,D); P2(A,B); P2(B,C); P2(D,A); (* A CALL OF P1(A,C) OR P1(B,D) WOULD BE INVALID BECAUSE OF INCONGRUITY *) 6 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 END (* MAIN *). (3) The standard syntax for conformant-array parameters is used. conformant-array-parameter-specification = [ "var" ] identifier { "," identifier } ":" conformant-array-schema . conformant-array-schema = packed-schema | unpacked-schema . packed-schema = "packed" "array" "[" index-type-specification "]" "of" type-identifier . unpacked-schema = "array" "[" index-type-specification { ";" index-type-specification } "]" "of" ( type-identifier | conformant-array-schema ) . index-type-specification = bound-identifier ".." bound-identifier ":" ordinal-type-identifier . A bound-identifier is neither a constant nor a variable. Assignment to a bound-identifier is not allowed. (4) An actual parameter type is conformable with (i.e., can be passed to) a conformant-array schema if all of the following are true. (a) The index type of both are compatible. (b) The index type bounds of the actual parameter lie within the closed interval of the index type specification of the conformant-array schema. (c) Both component types denote the same type or the component type of the actual parameter is conformable with the component conformant-array schema of the formal parameter. (d) Both are packed or both are unpacked type specifications. (5) The following extensions to the Standard are present in Release 4. (a) Formal conformant-array parameters can be passed as actual conformant-array value parameters. Example: PROCEDURE OUTER( A: ARRAY [LO1..HI1: INTEGER; LO2..HI2: INTEGER] OF REAL); PROCEDURE INNER(X: ARRAY [LO .. HI: INTEGER] OF REAL); BEGIN END (* INNER *); BEGIN (* OUTER *) INNER(A[LO1]) END (* OUTER *); (b) Packed conformant-arrays of char are treated as strings in certain cases (i.e., as parameters to WRITE). * 7 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 Example: Converting from Release 3 dynamic array parameters to Release 4 conformant-array parameters. (* OLD RELEASE 3 EXAMPLE *) TYPE VECTOR = ARRAY [INTEGER] OF REAL; FUNCTION MEAN(X: DYNAMIC VECTOR): REAL; VAR SUM: REAL; I: INTEGER; BEGIN (* MEAN *) SUM := 0.0; FOR I := LOW(X) TO HIGH(X) DO SUM := SUM + X[I]; MEAN := SUM / (HIGH(X) - LOW(X) + 1) END (* MEAN *); (* NEW RELEASE 4 EXAMPLE *) FUNCTION MEAN(X: ARRAY [LO .. HI: INTEGER] OF REAL): REAL; VAR SUM: REAL; I: INTEGER; BEGIN (* MEAN *) SUM := 0.0; FOR I := LO TO HI DO SUM := SUM + X[I]; MEAN := SUM / (HI - LO + 1) END (* MEAN *); Example: FUNCTION DOTPRODUCT(A,B: ARRAY [LO .. HI: INTEGER] OF REAL): REAL; VAR I: INTEGER; S: REAL; BEGIN (* DOTPRODUCT *) S := 0; FOR I := LO TO HI DO S := S + A[I] * B[I]; DOTPRODUCT := S END (* DOTPRODUCT *); This example illustrates a procedure that uses two actual parameters which share a conformant-array schema to ensure that the parameters are of the same type. Example: FUNCTION LENGTH(S : PACKED ARRAY [LO .. HI: INTEGER] OF CHAR) : INTEGER; (* RETURN LENGTH OF STRING PARAMETER. *) BEGIN (* LENGTH *) IF LO <> 1 THEN HALT(' PARAMETER MUST BE A STRING TYPE.'); LENGTH := HI - LO + 1 END (* LENGTH *); 8 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 Example: FUNCTION POS(PAT: PACKED ARRAY [L1 .. H1: INTEGER] OF CHAR; SRC: PACKED ARRAY [L2 .. H2: INTEGER] OF CHAR) : INTEGER; (* RETURN STARTING POSITION OF 'PAT' IN SOURCE STRING 'SRC'. RETURN ZERO IF SUBSTRING 'PAT' NOT FOUND IN 'SRC' *) VAR I,J,K,P: INTEGER; BEGIN (* POS *) IF L1 <> 1 THEN HALT(' PAT MUST BE A STRING TYPE.'); IF L2 <> 1 THEN HALT(' SRC MUST BE A STRING TYPE.'); P := 0; I := L2; WHILE (P = 0) AND (I < H2) DO BEGIN IF PAT[L1] = SRC[I] THEN BEGIN P := I; K := I; J := L1; WHILE (P <> 0) AND (J < H1) DO BEGIN IF K = H2 THEN P := 0 ELSE BEGIN K := K + 1; J := J + 1; IF PAT[J] <> SRC[K] THEN P := 0 END END END; I := I + 1 END; POS := P END (* POS *); ______________ +2.3. FOR STATEMENTS The Pascal Standard, and thus Release 4, restricts the use of for-statement control variables in order to ensure the security of the control variable throughout the lifetime of the for-statement. (1) The control variable of a for-statement must be a local variable and must not be a formal parameter. A non-local (global) variable cannot be used as a for-statement control variable. (2) Neither any statement inside a for-statement nor any procedure or function inside of the block which declares the control variable can THREATEN the control variable. Each of the following constitutes a threat. (a) An assignment statement assigns to the control variable. (b) Another for-statement uses the same control variable. (c) The control variable occurs as an actual variable parameter. (d) The control variable is a parameter to READ or READLN. 9 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 Example of INVALID usage: PROGRAM EXAMPLE(INPUT,OUTPUT); VAR I, J, K: INTEGER; PROCEDURE NAUGHTY; BEGIN (* NAUGHTY *) I := 3 (* THIS THREATENS I *) END (* NAUGHTY *); PROCEDURE INSPECT(A: INTEGER); BEGIN (* INSPECT *) ... END (* INSPECT *); PROCEDURE ALTER(VAR B: INTEGER); BEGIN (* ALTER *) ... END (* ALTER *); PROCEDURE NASTY; BEGIN (* NASTY *) FOR J := 1 TO 10 DO INSPECT(J); (* INVALID -- J IS NOT LOCAL *) END (* NASTY *); BEGIN (* EXAMPLE *) FOR I := 1 TO 10 DO NASTY; (* INVALID -- I WAS THREATENED BY PROCEDURE NAUGHTY *) FOR K := 1 TO 100 DO BEGIN INSPECT(K); (* NOT AN ERROR *) ALTER(K); (* INVALID -- CANNOT PASS CONTROL VARIABLE AS AN ACTUAL VARIABLE PARAMETER *) K := 7; (* INVALID -- CANNOT CHANGE THE VALUE OF A CONTROL VARIABLE INSIDE THE FOR-STATEMENT *) READ(K); (* INVALID -- A CONTROL VARIABLE CANNOT BE A PARAMETER OF READ OR READLN *) FOR K := 3 TO 5 DO INSPECT(K); (* INVALID -- K IS ALREADY A CONTROL VARIABLE FOR AN ENCOMPASSING FOR- STATEMENT *) END END (* EXAMPLE *). (3) If the component-statement of the for-statement is to be executed, both the initial value and the final value must lie within the type of the control variable. 10 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 Example of INVALID usage: PROCEDURE WRONG; VAR I: 10..20; J: INTEGER; BEGIN (* WRONG *) FOR I := 1 TO 20 DO SOMETHING; (* INVALID -- INITIAL VALUE IS NOT WITHIN THE TYPE OF I *) J := 100; FOR I := J TO 35 DO SOMETHING; (* NOT AN ERROR -- LOOP WILL NOT BE EXECUTED *) END (* WRONG *); ________________________ +2.4. ASSIGNMENTS TO FUNCTIONS Release 4 follows the Pascal Standard regarding assignments to functions. The following are differences from earlier releases. (1) An assignment to a function identifier may occur anywhere inside the block of the function (unless the function name is redefined in an inner scope -- see 2.11 below concerning scope rules). This differs from earlier releases in that the assignment statement now may occur within a procedure or function that is nested within the function that is being defined. Example: FUNCTION OUTER(J: INTEGER): INTEGER; PROCEDURE INNER(K: INTEGER); BEGIN IF K >= 10 THEN OUTER := K ELSE OUTER := 10 END (* INNER *) ; BEGIN (* OUTER *) INNER(J) END (* OUTER *) ; (2) The block of a function must contain at least one assignment statement that assigns to that function. It is a compiler-detected violation if no such assignment statement occurs. 11 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 __________________________ +2.5. LABELS AND GOTO STATEMENTS Release 4 enforces the standard rules governing the use of labels and goto-statements. These rules are more restrictive than the rules enforced by earlier releases of Pascal-6000 in the following ways. (1) Every label must be an unsigned integer less than or equal to 9999. (2) Every label that is declared must prefix a statement. (3) A goto-statement may contain a label only if one or more of the following conditions is true. (a) The label prefixes a statement that contains the goto-statement. Example: 1: IF A THEN PROC ELSE BEGIN PROC2; GOTO 1 END (b) The label prefixes one of the statements of a statement-sequence and the goto-statement is contained by another statement of the same sequence. Example: REPEAT 1: PROC1; IF CONDITION THEN BEGIN PROC2; GOTO 1 END; PROC3 UNTIL OTHERCONDITION (c) The label prefixes an unnested statement of the statement-part of a procedure or function and the goto-statement occurs in a another procedure or function that is nested within the first one. Example: PROCEDURE OUTER; LABEL 1; PROCEDURE SANCTUM; BEGIN (* SANCTUM *) IF CONDITION THEN GOTO 1 END (* SANCTUM *) ; BEGIN (* OUTER *) INITIALIZE; SANCTUM; IF HAPPY THEN BEGIN SOMETHING; SOMETHINGELSE END; 1: FINALIZE END (* OUTER *) ; Here, the label 1 could not prefix a statement inside the if-statement ("IF HAPPY THEN...") because then it would not prefix an unnested statement. 12 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 _______________ +2.6. PACK AND UNPACK The standard procedures PACK and UNPACK have changed to conform to the standard. (1) The Standard requires that the element types of the packed and unpacked arrays be identical. Previously, the element types only had to be compatible. (2) The index types of the packed and unpacked arrays need not be compatible. (3) Earlier releases of Pascal-6000 did not allow PACK and UNPACK to be used on arrays that were declared as PACKED, but that were not actually packed in memory. If each element of the PACKED array occupied one or more words of storage, Pascal-6000 would not actually pack the array, whether it was declared to be PACKED or not, and would not allow PACK and UNPACK to be used on such an array. The Standard requires only that the packed array be declared as PACKED. ____ +2.7. PAGE Release 4 implements the predeclared procedure PAGE in such a way as to conform to the Standard. The following differences from earlier releases exist. (1) PAGE no longer requires a parameter; the default parameter is the standard file OUTPUT. (2) PAGE(F) no longer implicitly performs a WRITELN(F) unless the last operation on file F left a partial line. Example: BEGIN REWRITE(F); PAGE(F); (* no WRITELN(F) is performed. *) WRITELN(F, ' STUFF'); PAGE(F); (* no WRITELN(F) is performed. *) WRITE(F, ' PARTIAL LINE '); PAGE(F) (* a WRITELN(F) is performed before the page-eject. *) END ________________________ +2.8. PARAMETER-LIST CONGRUITY Congruity is used to determine whether a procedure or function may be passed as an actual parameter; a procedure's or function's parameter list must be congruous with the parameter list of the formal parameter. Release 4 enforces parameter list congruity as specified in the ISO Standard. 13 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 Example: PROGRAM MAIN; PROCEDURE X(PROCEDURE F(A, B : REAL)); BEGIN (* X *) END; PROCEDURE PROC1(R, S : REAL); BEGIN (* PROC1 *) END; BEGIN (* MAIN *) X(PROC1) END (* MAIN *). Here, the parameter list of PROC1 must be congruous with the parameter list of F in order for the statement "X(PROC1)" to be valid. Two formal parameter lists are congruous if they contain the same number of formal parameter sections and if the corresponding formal parameter sections match. Two formal parameter sections match if any of the following is true. (a) Both are value parameter specifications, both contain the same number of parameters, and their type identifiers represent the same type. (b) Both are variable parameter specifications, both contain the same number of parameters, and their type identifiers represent the same type. (c) Both are procedural parameter specifications or both are functional parameter specifications and the formal parameter lists of both are congruous, and the result types of functional parameter specifications are the same. (d) Both are value conformant array specifications or both are variable conformant array specifications, and in both cases contain the same number of parameters, and the conformant array schemas of both are equivalent. Two conformant array schemas are equivalent if all of the following four statements are true. (1) There is a single index type specification in each conformant array schema. (2) The ordinal type identifier in each index type specification denotes the same type. (3) Either the (component) conformant array schemas of the conformant array schemas are equivalent or the type identifiers of the conformant array schemas denote the same type. (4) Either both conformant array schemas are packed or both are not packed. 14 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 Example: The following parameter lists are NOT congruous. (A,B: INTEGER) (A: INTEGER; B: INTEGER) (A: ARRAY [LO1 .. HI1: INTEGER] OF REAL; B: ARRAY [LO2 .. HI2: INTEGER] OF REAL) (A,B: ARRAY [LO .. HI: INTEGER] OF REAL) (X,Y: REAL; P,Q: CHAR) (X: REAL; Y: REAL; P,Q: CHAR) _________________________ +2.9. TEXTFILE INPUT AND OUTPUT Release 4 implements the standard procedures READ and WRITE according to the Pascal Standard. The differences from earlier releases are as follows. (1) A variable passed to READ now may be a component of a packed array or of a packed record. (2) READ will now terminate execution if the end of file is encountered after skipping spaces. In previous releases, READ would return an "undefined" value under these conditions. It is not good practice to assume the format of an input file: there should be a number present on the file before calling READ to read numbers from that file. The functions EOFS and EOLNS described in the TEXTIO chapter of the Pascal-6000 writeup can be helpful. Example: IF EOFS(INPUT) THEN WRITELN(OUTPUT, ' READ PAST END OF FILE.') ELSE IF INPUT^ IN ['0'..'9'] THEN READ(INPUT, NUMBER) ELSE WRITELN(OUTPUT, ' DIGIT EXPECTED.') (3) Writing a Boolean expression is now equivalent to writing one of the strings 'FALSE' or 'TRUE'. (4) Zero and negative format widths are no longer allowed by the compiler. Example of INVALID usage: WRITE(OUTPUT, NUMBEROFITEMS:0); WRITE(DATA, VARIANCE:10:0); WRITELN(CLASSDATA, STUDENTS:-1); (5) Attempting to write an undefined expression is an error. Previously, Pascal-6000 represented undefined expressions on output with the string 'UNDEF'. (6) The floating-point output format no longer generates an "extra" space at the beginning of the number. Now the first character written is a 15 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 "-" if the number is negative, or a single space otherwise. Because of this, one more significant digit will be written in the same field width, compared with Release 3. Therefore, in many programs, the field widths for floating-point output may be decreased by one to compensate. Examples: WRITE( 1.0 : 1 ) generates " 1.0E+000" WRITE( -1.0 : 1 ) generates "-1.0E+000" To keep the same default number of significant digits, the default field width for real writes has been decreased from 22 to 21. Examples: WRITE( 1.0 ) generates " 1.0000000000000E+000" WRITE( -1.0 ) generates "-1.0000000000000E+000" (7) Use of OCT and HEX for integer output to textfiles has been eliminated. The procedures WRITEHEX and WRITEOCT are now used; these are described in the RADIXIO chapter of the Pascal Library Information writeup. ____________ +2.10. RECORD TYPES Release 4 implements record-types according to the Pascal Standard. The differences from earlier releases are as follows. (1) Fields within variants now may possess a type that is a file type or that contains a file type. (However, storage for the file variable does NOT overlay storage for other variants.) (2) Variant-parts of records must be completely specified; this means that every value of the tag type must be represented by a constant prefixing a variant in that variant part, or the OTHERWISE clause must be used to | represent all constants not appearing in any other case constant list | in that variant part. Thus, for example, "RECORD CASE INTEGER OF ... " | would in practice require the use of an OTHERWISE clause; without it, | every integer would have to be used as a case constant "label". Most | uses of integer labels can be handled easily by declaring a subrange. Examples: TYPE TAGTYPE = 1..3; RECTYPE = RECORD CASE TAG: TAGTYPE OF 1: (FIELD1: INTEGER); 2: (); 3: (FIELDX: REAL) END; REC2TYPE = RECORD CASE INTEGER OF | -10..-1: (VAL: INTEGER); | 0: (); | 1..9: (DIGIT: CHAR); | OTHERWISE (INVALID: BOOLEAN) | END; | 16 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 (3) Similarly, no constant prefixing a variant may lie outside the corresponding tag type. For example, given TAGTYPE as defined above, "RECORD CASE TAGTYPE OF 1, 2, 3: (); 4: () END" is not valid because the constant 4 lies outside of the range of the type "TAGTYPE". (4) A tag field may not be passed as an actual variable parameter. It may, of course, be passed as a value parameter. (5) A bug which prevented a tag field having the same spelling as a type identifier has been fixed. The following is now valid. Example: RECORD CASE INTEGER: BOOLEAN OF TRUE: (); FALSE: () END (6) It is no longer valid for two semicolons to be adjacent inside a record type. ___________ +2.11. SCOPE RULES Release 4 enforces the standard rules governing the scope of identifiers. These rules are more restrictive than the rules enforced by earlier releases of Pascal-6000 in the following ways. (1) Within a scope (e.g., procedure body) where an identifier is declared, all uses of that spelling in that scope must appear after the place of declaration, with one exception. The exception allows a spelling of a type-identifier to be used in a pointer type that occurs prior to the declaration of the type-identifier. (For example, the type definition "P = ^ T" may occur before the definition of T, so long as they both occur in the same type- definition-part.) Example of INVALID usage: PROGRAM RENAME; CONST BIG = MAXINT; (* MAXINT is predeclared *) MAXINT = 0; (* MAXINT is redefined *) BEGIN END. (2) The use of an identifier in a nested scope prohibits redefinition of that identifier in a scope encompassing the nested scope that is itself nested within the definition of the identifier. Example of INVALID usage: TYPE R = RECORD S: RECORD X: ^ T; END; T: INTEGER END; T = REAL; 17 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 Here, there is a conflict between the use of "T" in the inner record-type and the use of "T" as a field-identifier in the outer record-type. Thus, this program fragment is not a valid type-definition part. (3) The scope of a parameter identifier extends over the entire parameter list in which it is declared, and also over the block of the procedure or function corresponding to that parameter list. However, the scope includes neither the procedure or function name nor the result-type identifier of the function. Example: FUNCTION F (G: INTEGER) : G; BEGIN PROC(G); F := SOMETHING END; Here, the use of "G" for a formal parameter does not conflict with the use of "G" for the result type. In the following example the use of "P" for a formal parameter does not conflict with the use of "P" as the procedure name, but it does prevent the procedure from calling itself because "P" inside the procedure's block can only refer to the parameter. Example: PROCEDURE P(VAR P: INTEGER); BEGIN P := P + 1 END _______________ +2.12. LEXICAL SYMBOLS Release 4 processes lexical symbols according to the Pascal Standard. The following are differences from earlier releases. (1) Identifier spellings are distinguished by ALL characters, rather than the first ten as in earlier releases. The number of characters treated as significant in an identifier now is limited only by the maximum length of a source program line (see chapter LIMITS of the Pascal-6000 writeup). Thus the following two identifiers will be recognized by the compiler as distinct. AVERYLONGIDENTIFIERALAS AVERYLONGIDENTIFIERALSO However, this does not change certain other implementation restrictions related to the length of identifiers. For example, PMD (the Post-Mortem Display) provides only the first ten characters of an identifier. Also, names passed to the Control Data loaders, such as when the "E" compiler option is used, are still restricted to seven characters. (2) A numeric constant immediately followed by a reserved symbol now must be separated by a space, comment, or end-of-line. In previous releases, the compiler allowed the following INVALID construct. 18 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 5DIV J (* INVALID - should be 5 DIV J *) (3) NIL is now treated as a reserved symbol; the spelling "NIL" can no longer be used for identifiers. (4) Nested comments are no longer allowed. (5) The following alternative symbols are recognized by Release 4. Traditional Alternative ----------- ----------- ^ @ [ (. ] .) (6) The only comment delimiters supported are (* and *). (7) Several nonstandard representations of symbols under the CDC Scientific character set (A- compiler option) are no longer recognized. The following table lists characters that are no longer allowed under the CDC Scientific character set (Old Symbols) followed by the corresponding standard symbols that must now be used (Standard Symbols). Old Symbols Standard Symbols ----------- ---------------- Display Scientific Code Graphic Symbol Meaning ---- ------- ------ ------- 65B right arrow (* open comment 71B down arrow *) close comment 74B less than or equal <= less than or equal 75B greater than or equal >= greater than or equal 64B not equal <> not equal 67B logical and AND Boolean and 66B logical or OR Boolean or 76B logical not NOT Boolean not (8) The apparent integer value of a label must be in the range 0..9999. Note that 09999 is a valid label, and is equivalent to 9999. (9) The underscore character may be used in an identifier as a separator. | See the chapter SYMBOLS in the Pascal-6000 writeup for details. | 19 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 _______________ +3. LIBRARY CHANGES The following items briefly describe changes to the "extended" Pascal-6000 library. Details about these and other library packages are found in the Pascal-6000 document "Pascal Library Information". ___________________________________ +3.1. LIBRARY PACKAGES CHANGED OR REMOVED - CSIMAGE, DUMP and OPTION are now accessible as INCLUDE packages. - The IOAIDS package now defines type SEGTEXT = SEGMENTED TEXT. SEGTEXT was predefined in Release 3 but is not in Release 4. - In the PASPLOT package, the DRAWREAL floating-point format now plots one less leading space than it did in Release 3. This corresponds to the change in the predeclared procedure WRITE (see 2.9 (6), above). - SORT has been renamed to QSORT, and the EXTERN declaration in all programs using it must also change to use conformant array parameters instead of "dynamic" array parameters. ______________ +3.2. PACKAGES ADDED - COMPLEX supports operations on complex numbers. - CSORT and CSORTS each define a procedure for sorting linked lists. | - PAGSIZ manipulates page size parameters. | - RADIXIO supports output of integers in octal and hexadecimal representations. The following new packages are available only under the NOS 1 and NOS 2 operating systems. - LFM offers access to Local File Manager functions. - PFM offers access to Permanant File Manager functions. - ROUTE provides access to file disposition. | - SBCOPY does a fast file-to-file copy. - SYSPROC supports miscellaneous system functions. - TSAIDS provides interactive computing aids. 20 1 Pascal-6000 Release 4 Upgrade Guide 27 May 86 ________________ +4. INTERNAL CHANGES There have been many changes internally. Details can be found in the Pascal-6000 Internal Reference Manual. Most notable are: - Memory management, which requires that all memory allocation and deallocation be done by the PMM routines. An interface to Common Memory | Manager (CMM) has been added. See chapters MEMORY and CMM in the | Pascal-6000 writeup. | - Procedure and function (and program) code formats have changed, along with block entry and exit code. The layout of activation records has also changed. The stack of activation records is now implemented as a linked list. - The interface with the operating system for error recovery (REPRIEVE, EREXIT, or RECOVR) has changed for some systems, and now can be disabled on all systems by completely suppressing PMD (by setting the P compiler option to zero over the entire program). - The changes necessary to support the SCOPE 2 system have been integrated into the OLDPL's. - We have defined symbolic constants for offsets and bit positions in the EFET data structure. We have converted the run-time system and library to use these symbols. 21