146 van Wijngaarden, et al.gg) On sequential access books, undefined (10.3.1.4.a) is called ifbinary and character transput is alternated, i.e., after opening or resetting(10.3.1.6.j), either is possible but, once one has taken place, the other ma~not until after another reset.hh) On sequential aecess books, output immediately causes the logicalend of the book to be moved to the current position (unless both are in thesame line); thus input may not follow output without first resetting(10.3.1.6.j).Example:begin file fl, f2; [ 1 : 10000 ] int x; int n : = O;open (fl, "", channel 2);f2:=fl;¢ now fl and f2 can be used interchangeably ¢make cony (fl, flexocode); make cony (f2, telexcode);¢ now fl and f2 use different codes; flexocode and telexcode aredefined in the library-prelude for this implementation ¢reset (fl);¢ consequently, f2 is reset too ¢on logical file end (fl, (ref file f) bool : goto done);fori doget (fl, x [i]); n := i od;¢ too bad if there are more than i0000 integers in the input ¢done:reset (fl); fori to n do put (f2, x [i]) od;close (f2) ¢ fl is now closed too ¢end }a) mode file =struct (ref book 9 book, union (flextext, text) 9 text, channel 9 chan,ref format 9 format, ref int 9 forp,ref bool 9 read mood, 9 write mood, 9 char mood, 9 bin mood,9 opened,ref pos 9 cpos ¢ current position ¢,string 9 term ¢ string terminator ¢,cony 9 cony ¢ character conversion key ¢,proc (ref file) bool 9 logical file mended, 9 physical file mended,.*page mended, 9 line mended, 9 format mended,9 value error mended,proc (ref file, tel char) bool 9 char error mended) ;b) proc get possible = (ref flle f) bool :(opened of fl (get of chan off) (book of f) l undefined; skip) ;c) proc put possible = (ref file f) bool :(opened of fl (put of chan of f) (book of f) l undefined; skip) ;d) proc bin possible = (ref file f) boos:(opened of f l (bin of chan o!f) (book off) I undefined; skip) ;e)g)h)J)k)1)m)n)o)p)q)r)s)ALGOL <strong>68</strong> Revised Reportproc compressible = (tel file f) bool :(opened off (compress of chan off) (book of f) l undefined; skip) ;proc reset possible = (tel file f) bool :(opened off (reset of chan off) (book of f) l undefined; skip) ;proc set possible = (ref file f) bool :(opened of fl (set of chan off) (book off) [ undefined; skip) ;proc reidf possible = (ref file f) bool :(opened off (reidf of chan off) (book off) I undefined; skip) ;proc chan = (ref file f) channel:(opened offl chan of fl undefined; skip);proc make cony = (ref file f, proc (ref book) conv c) void :(opened of fi cony off:= c (book oil) I undefined) ;proc make term = (ref file f, string t) void : term off: = t ;proc on logical file end = (ref file f, proc (ref file) bool p) void :logical file mended off: = p ;proc on physical file end = (ref file f, proc (ref file) bool p) void :physical file mended off: = p ;proc on page end = (tel file f, proc (ref file) bool p) void :page mended off: = p ;proc on line end = (ref file f, proc (ref file) bool p) void :line mended off: = p ;proc on format end = (ref file f, proc (ref file) bool p)void :format mended off: = p ;proc on value error = (ref file f, proc (ref file) bool p) void :value error mended off : = p ;proc on char error = (ref file f, proc (ref file, ref char) bool p) void :char error mended off: = p ;proc reidf = (ref file f, string idf) void :if opened off ^ reidf possible (f) a idf ok (idf)then idf of book off: = idffl;10.3.1.4. Opening and closing files{aa) When, during transput; something happens which is left undefined,for example by explicitly calling undefined (a), this does not imply thatthe elaboration is catastrophically and immediately interrupted (2.1.4.3.h),but only that some sensible action is taken which is not or cannot bedescribed by this Report alone and is generally implementation-dependent.147
148 van Wijngaarden, etal.bb) A book is "linked" with a file by means of establish (b), create (c)or open (d). The linkage may be terminated by means of close (n), lock(o) or scratch (p).cc) When a file is "established" on a channel, then a book is generated(5.2.3) with a text of the given size, the given identification string, withputting set to true, and the logical end of the book at (1, 1, 1). Animplementation may require (g) that the characters forming theidentification string should be taken from a limited set and that the stringshould be limited in length. It may also prevent two books from having thesame string. If the establishing is completed successfully, then the value 0is returned: otherwise, some nonzero integer is returned (the value of thisinteger might indicate why the file was not established successfully).When a file is "created" on a channel, then a file is established with abook whose text has the default size for the channel and whoseidentification string is undefined.dd) When a file is "opened", then the chain of backfiles is searched forthe first book which is such that match (h) returns true. (The precisemethod of matching is not defined by this Report and will, in general, beimplementation dependent. For example, the string supplied as parameterto open may include a password of some form.) If the end of the chain ofbackfiles is reached or if a book has been selected, but putting of the bookyields true, or if putting to the book via the channel is possible and thebook is already open, then the further elaboration is undefined. If the fileis already open, an up gremlins provides an opportunity for an appropriatesystem action on the book previously linked (in case no other copy of thefile remains to preserve that linkage).ee) The routine associate may be used to associate a file with a valueof the mode specified by either ref [ ] char, ref [ ] [ ] char or ref [ ] [ ] [ ]char, thus enabling such variables to be used as the book of a file.ff) When a file is "closed", its book is attached to the chain ofbackfiles referenced by chainbfile. Some system-task is then activated bymeans of an up gremlins. (This may reorganize the chain of backfiles,removing this book, or adding further copies of it. It may also cause thebook to be output on some external device.)gg) When a file is "locked", its book is attached to the chain ofbackfiles referenced by lockedbfile. Some system-task is then activated bymeans of an up gremlins. A book which has been locked cannot be reopeneduntil some subsequent system-task has re-attached the book to thechain of backfiles available for opening.hh) When a file is "scratched", some system-task is activated bymeans of an up gremlins. (This may cause the book linked to the file to bedisposed of in some manner.)}a)b)c)d)ALGOL <strong>68</strong> Revised Report 149proc .~ undefined = int : c some sensible system action yielding aninteger to indicate what has been done; it is presumed that thesystem action may depend on a knowledge of any valuesaccessible 12.1.2.c} inside the locale of any environ which is olderthan that in which this pseudo-comment is being elaborated{notwithstanding that no ALGOL <strong>68</strong> construct written here couldaccess those values} c ;proc establish =(ref file file, string idf, channel chan, int p, l, c) int :begindown bfileprotect;PRIM book book : =(PRIMflex[l : p]flex[l : l]flex[l : c]char, (1,1,1), idf,true, 1);if file available (chan)^ (put of chan) (book)^ estab of chan^ - (pos (p, l, c) beyond max pos of chan)^ - (pos (1, 1, 1) beyondpos (p, l, c)) ^ idfok (idf)then(opened of file] up gremlins I up bfileprotect);file :=(book, text of book, chan, skip, skip,¢ state: ¢ heap bool : = false, heap bool : = true,heap bool : = false, heap bool : = false, heap bool : = true,heap pos : = (1, 1, 1), "", (standconv of chan) (book),¢ event routines: ¢ false, false, false, false, false, false,(ref file f, ref char a) bool : false);(" bin possible(file) I set char mood (file));0else up bfileprotect; undefinedfiend;proc create = (ref file file, channel chan) int :begin pos max pos = max pos of chan;establish (file, skip, chan, p of max pos, l of max pos,c of max pos)end;proc open = (ref file file, string idf, channel chan) int :begindown bfileprotect;if file available (chan)then ref ref bflle bf : = chainbfile; bool found : = false;while (ref bflle (bf) : ~: nil) ^ - found
- Page 2 and 3:
van Wijngaarden, et al.1.1.4.2. Par
- Page 4:
Acknowledgements{Habent sua fata li
- Page 8 and 9:
14 van Wijngaarden, et al.0.3.4. Mo
- Page 10 and 11:
. . . . . . . 4 " ' 0 . . . . . . .
- Page 12 and 13:
22 van Wijngaarden, et al.• let P
- Page 14 and 15:
26 van Wijngaarden, et al.{Since so
- Page 16 and 17:
30 van Wijngaarden, et aLloperandfo
- Page 18 and 19:
34 van Wijngaarden, et al.j) WHETHE
- Page 20 and 21:
38 van Wijngaarden, et al.A protono
- Page 22 and 23:
42 van Wijngaarden, et al.d) If N i
- Page 24 and 25: 46 van Wijngaarden, et al.c) {There
- Page 26 and 27: 50 van Wijngaarden, et al.c) The ph
- Page 28 and 29: 54 van Wijngaarden, et al.3.1.1. Sy
- Page 30 and 31: 58 van Wijngaarden, et al.where (RO
- Page 32 and 33: 62 van Wijngaarden, et al.1) SOlD N
- Page 34 and 35: 66 van Wijngaarden, et al.ALGOL 68
- Page 36 and 37: 70 van Wijngaarden, et el.For each
- Page 38 and 39: 74 van Wijngaarden, et al.If 'MODE"
- Page 40 and 41: 78 J van Wijngaarden, et al.C) SECO
- Page 42 and 43: 82 van Wijngaarden, et al.ALGOL 68
- Page 44 and 45: 86 van Wijngaarden. et al.ALGOL 68
- Page 46 and 47: 90 van Wijngaarden, et al.5.4.4.1.
- Page 48 and 49: 94van Wijngaarden, et al.ALGOL 68 R
- Page 50 and 51: 98 van Wijngaarden, et al.Assignati
- Page 52 and 53: 102 van Wijngaarden, et at.{A nest,
- Page 54 and 55: 106 van Wijngaarden, et al.'HEAD's
- Page 56 and 57: 110 van Wijngaarden, et al.ALGOL 68
- Page 58 and 59: 114van Wijngaarden, et al.ALGOL 68
- Page 60 and 61: 118 van Wijngaarden, et al.ALGOL 68
- Page 62 and 63: 122 van Wijngaarden, et al.style ii
- Page 64 and 65: 126 van Wijngaarden, et al.b) The c
- Page 66 and 67: 130van Wijngaarden, et al.ALGOL 68
- Page 68 and 69: 134van Wijngaarden, et al.ALGOL 68
- Page 70 and 71: 138d)e)f)g)h)i)J)k)1)m)n)van Wijnga
- Page 72 and 73: 142 van Wijngaarden, et al.physics
- Page 76 and 77: 150van Wijngaarden, et al.ALGOL 68
- Page 78 and 79: 154/van Wijngaarden, et al.ALGOL 68
- Page 80 and 81: 158 van Wijngaarden, et el.fi;ref p
- Page 82 and 83: 162van Wijngaarden, et al.ALGOL 68
- Page 84 and 85: 166van Wijngaarden, et al.ALGOL 68
- Page 86 and 87: 170/van Wijngaarden, etal.ALGOL 68
- Page 88 and 89: 174J)K)L)M)N)O)P)a)b)c)d)e)van Wijn
- Page 90 and 91: 178/van Wijngaarden, et al.ALGOL 68
- Page 92 and 93: 182 van Wijngaarden, et al.• let
- Page 94 and 95: 186van Wijngaarden, et al./ALGOL 68
- Page 96 and 97: 190 van Wijngaarden, etal.composed
- Page 98 and 99: 194h)i)J)van Wijngaa(rden, et al.pr
- Page 100 and 101: 198 van Wijngaarden, et al.¢ strin
- Page 102 and 103: 202tvan Wijngaarden, et al.ALGOL 68
- Page 104 and 105: 206 van Wijngaa~den. et al.10.3.6.1
- Page 106 and 107: 210 van Wijngaarden, et al.!ALGOL 6
- Page 108 and 109: 214 van Wijngaarden, et al.inoperat
- Page 110 and 111: 218fvan Wijngaarden, et al.¢ move
- Page 112 and 113: 222 van Wijngaarden, etaL{overflow}
- Page 114 and 115: 226 van Wijngaarden, et al.ALGOL 68
- Page 116 and 117: 230max int 10.2.1.cmax real 10.2.l.
- Page 118 and 119: 234 van Wijngaarden, et al.ALGOL 68