scsh-users
[Top] [All Lists]

Re: How to test for end of file?

To: back0003@gold.tc.umn.edu (back0003), bdc@life.ai.mit.edu
Subject: Re: How to test for end of file?
From: Olin Shivers <shivers@lambda.ai.mit.edu>
Date: Mon, 15 Jan 1996 15:56:09 -0500
Cc: scsh@martigny.ai.mit.edu
Reply-to: shivers@ai.mit.edu
   From: back0003@gold.tc.umn.EDU (back0003)
   Newsgroups: alt.lang.scheme.scsh

   Any clues are welcome.

   (define (witless-grep)
           (let ((temp-line (read-line my-file)))
             (if (= temp-line end-of-file)          ;; How to test for EOF?
                 #t
             (if (string-match my-regular-expression temp-line)
                   (begin
                     (write-string temp-line)
                     (newline)
                     (witless-grep))
                   (witless-grep)))))


   From: bdc@martigny.ai.mit.EDU (Brian D. Carlstrom)
   Message-ID: <199601151932.OAA26771@bloom-beacon.MIT.EDU>
   References: <Pine.LNX.3.91.960115140352.322A-100000@sacc.agoff.umn.edu>
   NNTP-Posting-Host: bloom-beacon.mit.edu
   I couldn't find this in the manual myself. I had to look in scsh.scm.


Use EOF-OBJECT?. You guys! This is R4RS. 

Jan's procedure would be written with the R4RS EOF-OBJECT? as

   (define (witless-grep)
     (let ((line (read-line my-file)))
       (cond ((not (eof-object? line))
              (cond ((string-match my-regular-expression line)
                     (write-string line)
                     (newline)))
              (witless-grep)))))

    -Olin

<Prev in Thread] Current Thread [Next in Thread>