|
|
1.1 ! root 1: .\" Copyright (c) 1980 Regents of the University of California. ! 2: .\" All rights reserved. The Berkeley software License Agreement ! 3: .\" specifies the terms and conditions for redistribution. ! 4: .\" ! 5: .\" @(#)pumanA.n 6.2 (Berkeley) 5/7/86 ! 6: .\" ! 7: .if !\n(xx \{\ ! 8: .so tmac.p \} ! 9: .ND ! 10: .nr H1 0 ! 11: .af H1 A ! 12: .NH ! 13: Appendix to Wirth's Pascal Report ! 14: .PP ! 15: This section is an appendix to ! 16: the definition of the Pascal language in Niklaus Wirth's ! 17: .I "Pascal Report" ! 18: and, with that Report, precisely defines the ! 19: Berkeley ! 20: implementation. ! 21: This appendix includes a summary of extensions to the language, ! 22: gives the ways in which the undefined specifications were resolved, ! 23: gives limitations and restrictions of the current implementation, ! 24: and lists the added functions and procedures available. ! 25: It concludes with a list of differences with the commonly available ! 26: Pascal 6000\-3.4 implementation, ! 27: and some comments on standard and portable Pascal. ! 28: .NH 2 ! 29: Extensions to the language Pascal ! 30: .PP ! 31: This section defines non-standard language constructs available in ! 32: .UP . ! 33: The ! 34: .B s ! 35: standard Pascal option of the translators ! 36: .PI ! 37: and ! 38: .PC ! 39: can be used to detect these extensions in programs which are to be transported. ! 40: .SH ! 41: String padding ! 42: .PP ! 43: .UP ! 44: will pad constant strings with blanks in expressions and as ! 45: value parameters to make them as long as is required. ! 46: The following is a legal ! 47: .UP ! 48: program: ! 49: .LS ! 50: \*bprogram\fP x(output); ! 51: \*bvar\fP z : \*bpacked\fP \*barray\fP [ 1 .. 13 ] \*bof\fP char; ! 52: \*bbegin\fP ! 53: z := 'red'; ! 54: writeln(z) ! 55: \*bend\fP; ! 56: .LE ! 57: The padded blanks are added on the right. ! 58: Thus the assignment above is equivalent to: ! 59: .LS ! 60: z := 'red ' ! 61: .LE ! 62: which is standard Pascal. ! 63: .SH ! 64: Octal constants, octal and hexadecimal write ! 65: .PP ! 66: Octal constants may be given as a sequence of octal digits followed ! 67: by the character `b' or `B'. ! 68: The forms ! 69: .LS ! 70: write(a:n \*boct\fP) ! 71: .LE ! 72: and ! 73: .LS ! 74: write(a:n \*bhex\fP) ! 75: .LE ! 76: cause the internal representation of ! 77: expression ! 78: .I a, ! 79: which must be Boolean, character, integer, pointer, or a user-defined enumerated ! 80: type, ! 81: to be written in octal or hexadecimal respectively. ! 82: .SH ! 83: Assert statement ! 84: .PP ! 85: An ! 86: .B assert ! 87: statement causes a ! 88: .I Boolean ! 89: expression to be evaluated ! 90: each time the statement is executed. ! 91: A runtime error results if any of the expressions evaluates to be ! 92: .I false . ! 93: The ! 94: .B assert ! 95: statement is treated as a comment if run-time tests are disabled. ! 96: The syntax for ! 97: .B assert ! 98: is: ! 99: .LS ! 100: \*bassert\fP <expr> ! 101: .LE ! 102: .SH ! 103: Enumerated type input-output ! 104: .PP ! 105: Enumerated types may be read and written. ! 106: On output the string name associated with the enumerated ! 107: value is output. ! 108: If the value is out of range, ! 109: a runtime error occurs. ! 110: On input an identifier is read and looked up ! 111: in a table of names associated with the ! 112: type of the variable, and ! 113: the appropriate internal value is assigned to the variable being ! 114: read. ! 115: If the name is not found in the table ! 116: a runtime error occurs. ! 117: .SH ! 118: Structure returning functions ! 119: .PP ! 120: An extension has been added which allows functions ! 121: to return arbitrary sized structures rather than just ! 122: scalars as in the standard. ! 123: .SH ! 124: Separate compilation ! 125: .PP ! 126: The compiler ! 127: .PC ! 128: has been extended to allow separate compilation of programs. ! 129: Procedures and functions declared at the global level ! 130: may be compiled separately. ! 131: Type checking of calls to separately compiled routines is performed ! 132: at load time to insure that the program as a whole ! 133: is consistent. ! 134: See section 5.10 for details. ! 135: .NH 2 ! 136: Resolution of the undefined specifications ! 137: .SH ! 138: File name \- file variable associations ! 139: .PP ! 140: Each Pascal file variable is associated with a named ! 141: .UX ! 142: file. ! 143: Except for ! 144: .I input ! 145: and ! 146: .I output, ! 147: which are ! 148: exceptions to some of the rules, a name can become associated ! 149: with a file in any of three ways: ! 150: .IP "\ \ \ \ \ 1)" 10 ! 151: If a global Pascal file variable appears in the ! 152: .B program ! 153: statement ! 154: then it is associated with ! 155: .UX ! 156: file of the same name. ! 157: .IP "\ \ \ \ \ 2)" ! 158: If a file was reset or rewritten using the ! 159: extended two-argument form of ! 160: .I reset ! 161: or ! 162: .I rewrite ! 163: then the given name ! 164: is associated. ! 165: .IP "\ \ \ \ \ 3)" ! 166: If a file which has never had ! 167: .UX ! 168: name associated ! 169: is reset or rewritten without specifying a name ! 170: via the second argument, then a temporary name ! 171: of the form `tmp.x' ! 172: is associated with the file. ! 173: Temporary names start with ! 174: `tmp.1' and continue by incrementing the last character in the ! 175: .SM ! 176: USASCII ! 177: .NL ! 178: ordering. ! 179: Temporary files are removed automatically ! 180: when their scope is exited. ! 181: .SH ! 182: The program statement ! 183: .PP ! 184: The syntax of the ! 185: .B program ! 186: statement is: ! 187: .LS ! 188: \*bprogram\fP <id> ( <file id> { , <file id > } ) ; ! 189: .LE ! 190: The file identifiers (other than ! 191: .I input ! 192: and ! 193: .I output ) ! 194: must be declared as variables of ! 195: .B file ! 196: type in the global declaration part. ! 197: .SH ! 198: The files input and output ! 199: .PP ! 200: The formal parameters ! 201: .I input ! 202: and ! 203: .I output ! 204: are associated with the ! 205: .UX ! 206: standard input and output and have a ! 207: somewhat special status. ! 208: The following rules must be noted: ! 209: .IP "\ \ \ \ \ 1)" 10 ! 210: The program heading ! 211: .B must ! 212: contains the formal parameter ! 213: .I output. ! 214: If ! 215: .I input ! 216: is used, explicitly or implicitly, then it must ! 217: also be declared here. ! 218: .IP "\ \ \ \ \ 2)" ! 219: Unlike all other files, the ! 220: Pascal files ! 221: .I input ! 222: and ! 223: .I output ! 224: must not be defined in a declaration, ! 225: as their declaration is automatically: ! 226: .LS ! 227: \*bvar\fP input, output: text ! 228: .LE ! 229: .IP "\ \ \ \ \ 3)" ! 230: The procedure ! 231: .I reset ! 232: may be used on ! 233: .I input. ! 234: If no ! 235: .UX ! 236: file name has ever been associated with ! 237: .I input, ! 238: and no file name is given, then an attempt will be made ! 239: to `rewind' ! 240: .I input. ! 241: If this fails, a run time ! 242: error will occur. ! 243: .I Rewrite ! 244: calls to output act as for any other file, except that ! 245: .I output ! 246: initially has no associated file. ! 247: This means that a simple ! 248: .LS ! 249: rewrite(output) ! 250: .LE ! 251: associates a temporary name with ! 252: .I output. ! 253: .SH ! 254: Details for files ! 255: .PP ! 256: If a file other than ! 257: .I input ! 258: is to be read, ! 259: then reading must be initiated by a call to the ! 260: procedure ! 261: .I reset ! 262: which causes the Pascal system to attempt to open the ! 263: associated ! 264: .UX ! 265: file for reading. ! 266: If this fails, then a runtime error occurs. ! 267: Writing of a file other than ! 268: .I output ! 269: must be initiated by a ! 270: .I rewrite ! 271: call, ! 272: which causes the Pascal system to create the associated ! 273: .UX ! 274: file and ! 275: to then open the file for writing only. ! 276: .SH ! 277: Buffering ! 278: .PP ! 279: The buffering for ! 280: .I output ! 281: is determined by the value of the ! 282: .B b ! 283: option ! 284: at the end of the ! 285: .B program ! 286: statement. ! 287: If it has its default value 1, ! 288: then ! 289: .I output ! 290: is ! 291: buffered in blocks of up to 512 characters, ! 292: flushed whenever a writeln occurs ! 293: and at each reference to the file ! 294: .I input. ! 295: If it has the value 0, ! 296: .I output ! 297: is unbuffered. ! 298: Any value of ! 299: 2 or more gives block buffering without line or ! 300: .I input ! 301: reference flushing. ! 302: All other output files are always buffered in blocks of 512 characters. ! 303: All output buffers are flushed when the files are closed at scope exit, ! 304: whenever the procedure ! 305: .I message ! 306: is called, and can be flushed using the ! 307: built-in procedure ! 308: .I flush. ! 309: .PP ! 310: An important point for an interactive implementation is the definition ! 311: of `input\(ua'. ! 312: If ! 313: .I input ! 314: is a teletype, and the Pascal system reads a character at the beginning ! 315: of execution to define `input\(ua', then no prompt could be printed ! 316: by the program before the user is required to type some input. ! 317: For this reason, `input\(ua' is not defined by the system until its definition ! 318: is needed, reading from a file occurring only when necessary. ! 319: .SH ! 320: The character set ! 321: .PP ! 322: Seven bit ! 323: .SM USASCII ! 324: is the character set used on ! 325: .UX . ! 326: The standard Pascal ! 327: symbols `and', 'or', 'not', '<=', '>=', '<>', ! 328: and the uparrow `\(ua' (for pointer qualification) ! 329: are recognized.\*(dg ! 330: .FS ! 331: \*(dgOn many terminals and printers, the up arrow is represented ! 332: as a circumflex `^'. ! 333: These are not distinct characters, but rather different graphic ! 334: representations of the same internal codes. ! 335: .FE ! 336: Less portable are the ! 337: synonyms tilde `~' ! 338: for ! 339: .B not , ! 340: `&' for ! 341: .B and , ! 342: and `|' for ! 343: .B or . ! 344: .PP ! 345: Upper and lower case are considered to be distinct.\*(st ! 346: .FS ! 347: \*(stThe proposed standard for Pascal considers them to be the same. ! 348: .FE ! 349: Keywords and built-in ! 350: .B procedure ! 351: and ! 352: .B function ! 353: names are ! 354: composed of all lower case letters. ! 355: Thus the identifiers GOTO and GOto are distinct both from each other and ! 356: from the keyword ! 357: \*bgoto\fP. ! 358: The standard type `boolean' is also available as `Boolean'. ! 359: .PP ! 360: Character strings and constants may be delimited by the character ! 361: `\'' ! 362: or by the character `#'; ! 363: the latter is sometimes convenient when programs are to be transported. ! 364: Note that the `#' character has special meaning ! 365: .up ! 366: when it is the first character on a line \- see ! 367: .I "Multi-file programs" ! 368: below. ! 369: .SH ! 370: The standard types ! 371: .PP ! 372: The standard type ! 373: .I integer ! 374: is conceptually defined as ! 375: .LS ! 376: \*btype\fP integer = minint .. maxint; ! 377: .LE ! 378: .I Integer ! 379: is implemented with 32 bit twos complement arithmetic. ! 380: Predefined constants of type ! 381: .I integer ! 382: are: ! 383: .LS ! 384: \*bconst\fP maxint = 2147483647; minint = -2147483648; ! 385: .LE ! 386: .PP ! 387: The standard type ! 388: .I char ! 389: is conceptually defined as ! 390: .LS ! 391: \*btype\fP char = minchar .. maxchar; ! 392: .LE ! 393: Built-in character constants are `minchar' and `maxchar', `bell' and `tab'; ! 394: ord(minchar) = 0, ord(maxchar) = 127. ! 395: .PP ! 396: The type ! 397: .I real ! 398: is implemented using 64 bit floating point arithmetic. ! 399: The floating point arithmetic is done in `rounded' mode, and ! 400: provides approximately 17 digits of precision ! 401: with numbers as small as 10 to the negative 38th power and as large as ! 402: 10 to the 38th power. ! 403: .SH ! 404: Comments ! 405: .PP ! 406: Comments can be delimited by either `{' and `}' or by `(*' and `*)'. ! 407: If the character `{' appears in a comment delimited by `{' and `}', ! 408: a warning diagnostic is printed. ! 409: A similar warning will be printed if the sequence `(*' appears in ! 410: a comment delimited by `(*' and `*)'. ! 411: The restriction implied by this warning is not part of standard Pascal, ! 412: but detects many otherwise subtle errors. ! 413: .SH ! 414: Option control ! 415: .PP ! 416: Options of the translators may be controlled ! 417: in two distinct ways. ! 418: A number of options may appear on the command line invoking the translator. ! 419: These options are given as one or more strings of letters preceded by the ! 420: character `\-' and cause the default setting of ! 421: each given option to be changed. ! 422: This method of communication of options is expected to predominate ! 423: for ! 424: .UX . ! 425: Thus the command ! 426: .LS ! 427: % \*bpi \-l \-s foo.p\fR ! 428: .LE ! 429: translates the file foo.p with the listing option enabled (as it normally ! 430: is off), and with only standard Pascal features available. ! 431: .PP ! 432: If more control over the portions of the program where options are enabled is ! 433: required, then option control in comments can and should be used. ! 434: The ! 435: format for option control in comments is identical to that used in Pascal ! 436: 6000\-3.4. ! 437: One places the character `$' as the first character of the comment ! 438: and follows it by a comma separated list of directives. ! 439: Thus an equivalent to the command line example given above would be: ! 440: .LS ! 441: {$l+,s+ listing on, standard Pascal} ! 442: .LE ! 443: as the first line of the program. ! 444: The `l' ! 445: option is more appropriately specified on the command line, ! 446: since it is extremely unlikely in an interactive environment ! 447: that one wants a listing of the program each time it is translated. ! 448: .PP ! 449: Directives consist of a letter designating the option, ! 450: followed either by a `+' to turn the option on, or by a `\-' to turn the ! 451: option off. ! 452: The ! 453: .B b ! 454: option takes a single digit instead of ! 455: a `+' or `\-'. ! 456: .SH ! 457: Notes on the listings ! 458: .PP ! 459: The first page of a listing ! 460: includes a banner line indicating the version and date of generation of ! 461: .PI ! 462: or ! 463: .PC . ! 464: It also ! 465: includes the ! 466: .UX ! 467: path name supplied for the source file and the date of ! 468: last modification of that file. ! 469: .PP ! 470: Within the body of the listing, lines are numbered consecutively and ! 471: correspond to the line numbers for the editor. ! 472: Currently, two special ! 473: kinds of lines may be used to format the listing: ! 474: a line consisting of a form-feed ! 475: character, control-l, which causes a page ! 476: eject in the listing, and a line with ! 477: no characters which causes the line number to be suppressed in the listing, ! 478: creating a truly blank line. ! 479: These lines thus correspond to `eject' and `space' macros found in many ! 480: assemblers. ! 481: Non-printing characters are printed as the character `?' in the listing.\*(dg ! 482: .FS ! 483: \*(dgThe character generated by a control-i indents ! 484: to the next `tab stop'. ! 485: Tab stops are set every 8 columns in ! 486: .UX . ! 487: Tabs thus provide a quick way of indenting in the program. ! 488: .FE ! 489: .SH ! 490: The standard procedure write ! 491: .PP ! 492: If no minimum field length parameter is specified ! 493: for a ! 494: .I write, ! 495: the following default ! 496: values are assumed: ! 497: .KS ! 498: .TS ! 499: center; ! 500: l n. ! 501: integer 10 ! 502: real 22 ! 503: Boolean length of `true' or `false' ! 504: char 1 ! 505: string length of the string ! 506: oct 11 ! 507: hex 8 ! 508: .TE ! 509: .KE ! 510: The end of each line in a text file should be explicitly ! 511: indicated by `writeln(f)', where `writeln(output)' may be written ! 512: simply as `writeln'. ! 513: For ! 514: .UX , ! 515: the built-in function `page(f)' puts a single ! 516: .SM ASCII ! 517: form-feed character on the output file. ! 518: For programs which are to be transported the filter ! 519: .I pcc ! 520: can be used to interpret carriage control, as ! 521: .UX ! 522: does not normally do so. ! 523: .NH 2 ! 524: Restrictions and limitations ! 525: .SH ! 526: Files ! 527: .PP ! 528: Files cannot be members of files or members of dynamically ! 529: allocated structures. ! 530: .SH ! 531: Arrays, sets and strings ! 532: .PP ! 533: The calculations involving array subscripts and set elements ! 534: are done with 16 bit arithmetic. ! 535: This ! 536: restricts the types over which arrays and sets may be defined. ! 537: The lower bound of such a range must be greater than or equal to ! 538: \-32768, and the upper bound less than 32768. ! 539: In particular, strings may have any length from 1 to 65535 characters, ! 540: and sets may contain no more than 65535 elements. ! 541: .SH ! 542: Line and symbol length ! 543: .PP ! 544: There is no intrinsic limit on the length of identifiers. ! 545: Identifiers ! 546: are considered to be distinct if they differ ! 547: in any single position over their entire length. ! 548: There is a limit, however, on the maximum input ! 549: line length. ! 550: This limit is quite generous however, currently exceeding 160 ! 551: characters. ! 552: .SH ! 553: Procedure and function nesting and program size ! 554: .PP ! 555: At most 20 levels of ! 556: .B procedure ! 557: and ! 558: .B function ! 559: nesting are allowed. ! 560: There is no fundamental, translator defined limit on the size of the ! 561: program which can be translated. ! 562: The ultimate limit is supplied by the ! 563: hardware and thus, on the \s-2PDP\s0-11, ! 564: by the 16 bit address space. ! 565: If ! 566: one runs up against the `ran out of memory' diagnostic the program may yet ! 567: translate if smaller procedures are used, as a lot of space is freed ! 568: by the translator at the completion of each ! 569: .B procedure ! 570: or ! 571: .B function ! 572: in the current ! 573: implementation. ! 574: .PP ! 575: On the \s-2VAX\s0-11, there is an implementation defined limit ! 576: of 65536 bytes per variable. ! 577: There is no limit on the number of variables. ! 578: .SH ! 579: Overflow ! 580: .PP ! 581: There is currently no checking for overflow on arithmetic operations at ! 582: run-time on the \s-2PDP\s0-11. ! 583: Overflow checking is performed on the \s-2VAX\s0-11 by the hardware. ! 584: .br ! 585: .ne 15 ! 586: .NH 2 ! 587: Added types, operators, procedures and functions ! 588: .SH ! 589: Additional predefined types ! 590: .PP ! 591: The type ! 592: .I alfa ! 593: is predefined as: ! 594: .LS ! 595: \*btype\fP alfa = \*bpacked\fP \*barray\fP [ 1..10 ] \*bof\fP \*bchar\fP ! 596: .LE ! 597: .PP ! 598: The type ! 599: .I intset ! 600: is predefined as: ! 601: .LS ! 602: \*btype\fP intset = \*bset of\fP 0..127 ! 603: .LE ! 604: In most cases the context of an expression involving a constant ! 605: set allows the translator to determine the type of the set, even though the ! 606: constant set itself may not uniquely determine this type. ! 607: In the ! 608: cases where it is not possible to determine the type of the set from ! 609: local context, the expression type defaults to a set over the entire base ! 610: type unless the base type is integer\*(dg. ! 611: .FS ! 612: \*(dgThe current translator makes a special case of the construct ! 613: `if ... in [ ... ]' and enforces only the more lax restriction ! 614: on 16 bit arithmetic given above in this case. ! 615: .FE ! 616: In the latter case the type defaults to the current ! 617: binding of ! 618: .I intset, ! 619: which must be ``type set of (a subrange of) integer'' at that point. ! 620: .PP ! 621: Note that if ! 622: .I intset ! 623: is redefined via: ! 624: .LS ! 625: \*btype\fP intset = \*bset of\fP 0..58; ! 626: .LE ! 627: then the default integer set is the implicit ! 628: .I intset ! 629: of ! 630: Pascal 6000\-3.4 ! 631: .SH ! 632: Additional predefined operators ! 633: .PP ! 634: The relationals `<' and `>' of proper set ! 635: inclusion are available. ! 636: With ! 637: .I a ! 638: and ! 639: .I b ! 640: sets, note that ! 641: .LS ! 642: (\*bnot\fR (\fIa\fR < \fIb\fR)) <> (\fIa\fR >= \fIb\fR) ! 643: .LE ! 644: As an example consider the sets ! 645: .I a ! 646: = [0,2] ! 647: and ! 648: .I b ! 649: = [1]. ! 650: The only relation true between these sets is `<>'. ! 651: .SH ! 652: Non-standard procedures ! 653: .IP argv(i,a) 25 ! 654: where ! 655: .I i ! 656: is an integer and ! 657: .I a ! 658: is a string variable ! 659: assigns the (possibly truncated or blank padded) ! 660: .I i \|'th ! 661: argument ! 662: of the invocation of the current ! 663: .UX ! 664: process to the variable ! 665: .I a . ! 666: The range of valid ! 667: .I i ! 668: is ! 669: .I 0 ! 670: to ! 671: .I argc\-1 . ! 672: .IP date(a) ! 673: assigns the current date to the alfa variable ! 674: .I a ! 675: in the format `dd mmm yy ', where `mmm' is the first ! 676: three characters of the month, i.e. `Apr'. ! 677: .IP flush(f) ! 678: writes the output buffered for Pascal file ! 679: .I f ! 680: into the associated ! 681: .UX ! 682: file. ! 683: .IP halt ! 684: terminates the execution of the program with ! 685: a control flow backtrace. ! 686: .IP linelimit(f,x)\*(dd ! 687: .FS ! 688: \*(ddCurrently ignored by pdp-11 ! 689: .X . ! 690: .FE ! 691: with ! 692: .I f ! 693: a textfile and ! 694: .I x ! 695: an integer expression ! 696: causes ! 697: the program to be abnormally terminated if more than ! 698: .I x ! 699: lines are ! 700: written on file ! 701: .I f . ! 702: If ! 703: .I x ! 704: is less than 0 then no limit is imposed. ! 705: .IP message(x,...) ! 706: causes the parameters, which have the format of those ! 707: to the ! 708: built-in ! 709: .B procedure ! 710: .I write, ! 711: to be written unbuffered on the diagnostic unit 2, ! 712: almost always the user's terminal. ! 713: .IP null ! 714: a procedure of no arguments which does absolutely nothing. ! 715: It is useful as a place holder, ! 716: and is generated by ! 717: .XP ! 718: in place of the invisible empty statement. ! 719: .IP remove(a) ! 720: where ! 721: .I a ! 722: is a string causes the ! 723: .UX ! 724: file whose ! 725: name is ! 726: .I a, ! 727: with trailing blanks eliminated, to be removed. ! 728: .IP reset(f,a) ! 729: where ! 730: .I a ! 731: is a string causes the file whose name ! 732: is ! 733: .I a ! 734: (with blanks trimmed) to be associated with ! 735: .I f ! 736: in addition ! 737: to the normal function of ! 738: .I reset. ! 739: .IP rewrite(f,a) ! 740: is analogous to `reset' above. ! 741: .IP stlimit(i) ! 742: where ! 743: .I i ! 744: is an integer sets the statement limit to be ! 745: .I i ! 746: statements. ! 747: Specifying the ! 748: .B p ! 749: option to ! 750: .I pc ! 751: disables statement limit counting. ! 752: .IP time(a) ! 753: causes the current time in the form `\ hh:mm:ss\ ' to be ! 754: assigned to the alfa variable ! 755: .I a. ! 756: .SH ! 757: Non-standard functions ! 758: .IP argc 25 ! 759: returns the count of arguments when the Pascal program ! 760: was invoked. ! 761: .I Argc ! 762: is always at least 1. ! 763: .IP card(x) ! 764: returns the cardinality of the set ! 765: .I x, ! 766: i.e. the ! 767: number of elements contained in the set. ! 768: .IP clock ! 769: returns an integer which is the number of central processor ! 770: milliseconds of user time used by this process. ! 771: .IP expo(x) ! 772: yields the integer valued exponent of the floating-point ! 773: representation of ! 774: .I x ; ! 775: expo(\fIx\fP) = entier(log2(abs(\fIx\fP))). ! 776: .IP random(x) ! 777: where ! 778: .I x ! 779: is a real parameter, evaluated but otherwise ! 780: ignored, invokes a linear congruential random number generator. ! 781: Successive seeds are generated as (seed*a + c) mod m and ! 782: the new random number is a normalization of the seed to the range 0.0 to 1.0; ! 783: a is 62605, c is 113218009, and m is ! 784: 536870912. ! 785: The initial seed ! 786: is 7774755. ! 787: .IP seed(i) ! 788: where ! 789: .I i ! 790: is an integer sets the random number generator seed ! 791: to ! 792: .I i ! 793: and returns the previous seed. ! 794: Thus seed(seed(i)) ! 795: has no effect except to yield value ! 796: .I i. ! 797: .IP sysclock ! 798: an integer function of no arguments returns the number of central processor ! 799: milliseconds of system time used by this process. ! 800: .IP undefined(x) ! 801: a Boolean function. ! 802: Its argument is a real number and ! 803: it always returns false. ! 804: .IP wallclock ! 805: an integer function of no arguments returns the time ! 806: in seconds since 00:00:00 GMT January 1, 1970. ! 807: .NH 2 ! 808: Remarks on standard and portable Pascal ! 809: .PP ! 810: It is occasionally desirable to prepare Pascal programs which will be ! 811: acceptable at other Pascal installations. ! 812: While certain system dependencies are bound to creep in, ! 813: judicious design and programming practice can usually eliminate ! 814: most of the non-portable usages. ! 815: Wirth's ! 816: .I "Pascal Report" ! 817: concludes with a standard for implementation and program exchange. ! 818: .PP ! 819: In particular, the following differences may cause trouble when attempting ! 820: to transport programs between this implementation and Pascal 6000\-3.4. ! 821: Using the ! 822: .B s ! 823: translator option may serve to indicate many problem areas.\*(dg ! 824: .FS ! 825: \*(dgThe ! 826: .B s ! 827: option does not, however, check that identifiers differ ! 828: in the first 8 characters. ! 829: .I Pi ! 830: and ! 831: .PC ! 832: also do not check the semantics of ! 833: .B packed . ! 834: .FE ! 835: .SH ! 836: Features not available in Berkeley Pascal ! 837: .IP ! 838: Segmented files and associated functions and procedures. ! 839: .IP ! 840: The function ! 841: .I trunc ! 842: with two arguments. ! 843: .IP ! 844: Arrays whose indices exceed the capacity of 16 bit arithmetic. ! 845: .SH ! 846: Features available in Berkeley Pascal but not in Pascal 6000-3.4 ! 847: .IP ! 848: The procedures ! 849: .I reset ! 850: and ! 851: .I rewrite ! 852: with file names. ! 853: .IP ! 854: The functions ! 855: .I argc, ! 856: .I seed, ! 857: .I sysclock, ! 858: and ! 859: .I wallclock. ! 860: .IP ! 861: The procedures ! 862: .I argv, ! 863: .I flush, ! 864: and ! 865: .I remove. ! 866: .IP ! 867: .I Message ! 868: with arguments other than character strings. ! 869: .IP ! 870: .I Write ! 871: with keyword ! 872: .B hex . ! 873: .IP ! 874: The ! 875: .B assert ! 876: statement. ! 877: .IP ! 878: Reading and writing of enumerated types. ! 879: .IP ! 880: Allowing functions to return structures. ! 881: .IP ! 882: Separate compilation of programs. ! 883: .IP ! 884: Comparison of records. ! 885: .SH ! 886: Other problem areas ! 887: .PP ! 888: Sets and strings are more general in \* ! 889: .UP ; ! 890: see the restrictions given in ! 891: the ! 892: Jensen-Wirth ! 893: .I "User Manual" ! 894: for details on the 6000\-3.4 restrictions. ! 895: .PP ! 896: The character set differences may cause problems, ! 897: especially the use of the function ! 898: .I chr, ! 899: characters as arguments to ! 900: .I ord, ! 901: and comparisons of characters, ! 902: since the character set ordering ! 903: differs between the two machines. ! 904: .PP ! 905: The Pascal 6000\-3.4 compiler uses a less strict notion of type equivalence. ! 906: In ! 907: .UP , ! 908: types are considered identical only if they are represented ! 909: by the same type identifier. ! 910: Thus, in particular, unnamed types are unique ! 911: to the variables/fields declared with them. ! 912: .PP ! 913: Pascal 6000\-3.4 doesn't recognize our option ! 914: flags, so it is wise to ! 915: put the control of ! 916: .UP ! 917: options to the end of option lists or, better ! 918: yet, restrict the option list length to one. ! 919: .PP ! 920: For Pascal 6000\-3.4 the ordering of files in the program statement has ! 921: significance. ! 922: It is desirable to place ! 923: .I input ! 924: and ! 925: .I output ! 926: as the first two files in the ! 927: .B program ! 928: statement. ! 929: .sp 2 ! 930: .SH ! 931: Acknowledgments ! 932: .PP ! 933: The financial support of William Joy and Susan Graham by ! 934: the National Science Foundation under grants ! 935: MCS74-07644-A04, MCS78-07291, and MCS80-05144, ! 936: and the William Joy by an ! 937: .SM IBM ! 938: Graduate Fellowship are gratefully acknowledged.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.