10.07.2015 Views

Algol 68 - ACM Digital Library

Algol 68 - ACM Digital Library

Algol 68 - ACM Digital Library

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!