Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!mcvax!unido!ecrcvax!bruno From: bruno@ecrcvax.UUCP (Bruno Poterie) Newsgroups: comp.lang.prolog Subject: end_of_file in BSI proposals Message-ID: <443@ecrcvax.UUCP> Date: Thu, 22-Oct-87 14:06:26 EST Article-I.D.: ecrcvax.443 Posted: Thu Oct 22 14:06:26 1987 Date-Received: Sun, 25-Oct-87 20:49:55 EST Reply-To: bruno@ecrcvax.UUCP (Bruno Poterie) Organization: ECRC, Munich 81, West Germany Lines: 80 Keywords: BSI eof read References: [line-eater] While reading the input-output section of the latest BSI standard proposal for built-in predicates [Draft 4, PS/201, IST/5/15 Prolog, June 87], I read something which caused my blood to boil: (page 28, section 12.3) ... read/1 - input a term read(Term) reads the next term from the current input stream and unifies it with Term. The input term must be followed by a period followed by a space, tab, carriage return, line feed or end of file. If end of file has been reached than read(Term) fails. Possible calls and errors. (a) The syntax of the input term must agree with current operator declarations. Otherwise, an error message is printed and the call fails. Examples. ..... ..... read(T) current input stream is: foo 123. and there is no prefix operator declaration for foo. The call aborts and a syntax error message is printed. First point: what may well occurs on a syntax error not caused by an operator? Second point: either the call fail or it aborts on an operator error, but not both! And having it abort the call means that any syntax error would force a direct return to the top-level ??? even inside consult ??? And, above all, third point: WHO WOULD SERIOUSLY WANT END-OF-FILE CAUSE read/1 TO FAIL ??? How then could we write loop such as: treat_file(F) :- see(F), repeat, read(T), treat_term(T), T = end_of_file, !, seen. when the two most famous such loops are the top-level and consult ??? How would you then distinguish between a syntax error and an end-of-file if the syntax error caused a fail ??? If, i say if, it was possible to define a standard error catching mechanism, a la setjmp/longjmp (C), or a la catch/throw (Lisp), or a la exception/raise (Ada), or whichever mechanism you like (although i have myself quite precise ideas about this subject), then, of course, we could admit that END-OF-FILE would raise/throw/longjmp a predefined error/event/exception, for which the user could define where and when it wants any exception/catch/setjmp he wants to cope localy with ... BUT... we don't have this standard. Or, if there where something like: eof(Stream) defined in the standard, we could at least manage to test before reading. BUT .. Anyway, can we really afford to redefine so much algorithms, and rewritte so much code, a lot of it being (Prolog) system code, just for the sake of a 'desire to change'? I know that there are several terms returned by read/1 on end of file: 'eof', 'end_of_file', ?-(end), etc... but, wouldn't it be simpler to try to standardise one of them? So Please, Please, you people of this BSI comittee, think again before it is too late! No implementer concerned with the users needs would ever implement such a semantic! We don't need a dead-born standard! ================================================================================ Bruno Poterie # ... une vie, c'est bien peu, compare' a un chat ... ECRC GmbH # tel: (49)89/92699-161 Arabellastrasse 17 # Tx: 5 216 910 D-8000 MUNICH 81 # mcvax!unido!ecrcvax!bruno West Germany # bruno%ecrcvax.UUCP@Germany.CSNET ================================================================================