🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #3143

Re: behavior of read/get0 at end_of_file

#3143
From: Richard A. O'Keefe
Date: Thu, 24 Mar 1988 03:06
51 lines
2707 bytes
In article <519@ecrcvax.UUCP>, bruno@ecrcvax.UUCP (Bruno Poterie) writes:
> I believe that the notation "eof" is quite standard in
> the UN*X system and already in some Prolog

I just grepped through the UNIX [UNIX is a trademark of AT&T] manuals,
and all I could find was the function feof(Stream).  None of the UNIX 
utilities I am familiar with uses "eof" to signify end of file.
Franz Lisp does something interesting:
	(ratom [Port [Eof]])
	(read  [Port [Eof]])
	(readc [Port [Eof]])
return the Eof argument (which defaults to nil) when you read the
end of the file, so you can get whatever takes your fancy.

> so i think we could maybe abandon the end_of_file notation of Quintus (sorry
> for you Richard, a compatibility switch could very easily turn it back anyway),

But it ***ISN'T*** a Quintus notation!  This is the notation used by
	DEC-10 Prolog
	EMAS Prolog
	C Prolog
	Quintus Prolog
	Stony Brook Prolog
	ALS Prolog
	Expert Systems International Prolog-2
	AAIS Prolog (in "Edinburgh" mode only)
and doubtless many others.  end_of_file IS the "de facto" standard.
Poterie's suggestions are good ones, but in order to overthrow the
de facto standard, they would have to be MUCH MUCH better, and they
aren't.

> but it is not an important point as the aim would be to discipline one's
> programming style by systematically using the test form: 
> 	eof(Term) 
> and never ever explicit the EOF term itself. Portability is great.

Beware.  While Quintus Prolog offers the library predicate
	is_endfile(?EndMarker)
there are other Prolog systems, such as AAIS Prolog, where there is a
predicate with a similar name which takes a Stream argument:
	is_eof(+Stream)
in AAIS Prolog means "is it the case that Stream is positioned at its end?".
Yes, portability is great, but would it not be more just to reward those
people (such as SICS, Saumya Debray, ALS, and others) who have tried to
provide it, by standardising their solution?

> As a side effect, close/1 is
> not strictly necessary anymore as the following sequence does the job:
> 		eof(EOF), put(EOF)
Um, what about INPUT streams?  And there is another reason for wanting
close/1:  it will close a stream which is not the current output stream.
Technical Details
Message-ID: <809@cresswell.quintus.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!sri-unix!quintus!ok
References: <608> <1197@kulcs.kulcs.uucp> <783@cresswell.quintus.UUCP> <519@ecrcvax.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!sri-unix!quintus!ok
From: ok@quintus.UUCP (Richard A. O'Keefe)
Newsgroups: comp.lang.prolog
Subject: Re: behavior of read/get0 at end_of_file
Message-ID: <809@cresswell.quintus.UUCP>
Date: 24 Mar 88 03:06:23 GMT
References: <608> <1197@kulcs.kulcs.uucp> <783@cresswell.quintus.UUCP> <519@ecrcvax.UUCP>
Organization: Quintus Computer Systems, Mountain View, CA
Lines: 51
Keywords: get0 read end_of_file