[plt-scheme] no #!eof

From: Abdulaziz Ghuloum (aghuloum at cs.indiana.edu)
Date: Tue Apr 15 02:40:21 EDT 2008

On Apr 15, 2008, at 1:49 AM, Neil Van Dyke wrote:
> I think the REPL giving supporting "segments" like that is  
> something that you would not see if reading from Unix/Posix input  
> streams, from string ports, or from any other other Scheme input  
> port I can think of.
>
> Do you see these "segments" supported by any input other than the  
> REPL?

Yes, at least in two ways.

First, you can get such segments with fifos under unix:

$ mkfifo test
$ mzscheme
Welcome to MzScheme v3.99.0.18 [3m], Copyright (c) 2004-2008 PLT  
Scheme Inc.
 > (define p (open-input-file "test"))
 > (read p)   ;;; blocks
^Z
[1]+  Stopped                 mzscheme
$ echo "Hello" > test
$ fg
mzscheme
Hello
 > (read p)
#<eof>
 > (read p)   ;;; blocks
^Z
[1]+  Stopped                 mzscheme
$ echo "" > test
$ fg
mzscheme
#<eof>

Additionally, you can construct such ports programmatically as custom  
input ports (R6RS):

Ikarus Scheme version 0.0.3+ (revision 1450, build 2008-04-14)
Copyright (c) 2006-2008 Abdulaziz Ghuloum

 > (let ([p (make-custom-textual-input-port "foo"
              (let ([n 0])
                (lambda (s i c)
                  (set! n (+ n 1))
                  (if (even? n) 0 (begin (string-set! s i #\a) 1))))
              #f #f #f)])
     (list (read-char p) (read-char p) (read-char p) (read-char p)))
(#\a #!eof #\a #!eof)

> If so, do you see a need to distinguish end-of-segment value from a  
> end-of-all-segments value?  Or is there ever an end-of-all- 
> segments, or just an infinite sequence of empty segments?

The problem is that the OS gives no indication of an "end-of-all- 
segments", so, what you have (practically speaking) is an infinite  
sequence of empty segments.  Scanning through http://www.r6rs.org/ 
final/html/r6rs-lib/r6rs-lib-Z-H-9.html , I see that eof is almost  
always referred to as "*an* end of file" with an occasional reference  
to "*the next* end of file", which indicates that input ports can  
have more than one data segment and eof.

Aziz,,,


Posted on the users mailing list.