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