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