scsh-users
[Top] [All Lists]

Re: How do you make an eof-object?

To: xjam@bdt.com
Subject: Re: How do you make an eof-object?
From: Olin Shivers <shivers@clark.lcs.mit.edu>
Date: Sun, 15 Jan 95 13:24:26 -0500
Cc: scsh-bugs@martigny.ai.mit.edu
Reply-to: shivers@mintaka.lcs.mit.edu
(define eof-object (call-with-input-file "/dev/null" read))

I know, I know. It's disgusting. But it is R4RS.

You can also fetch the eof-object from some module in S48. This is not R4RS,
but it is portable away from Unix.

Unfortunately, I don't see better alternatives. I can't use #f or other value,
because they might be legitimate return values. I *could* require the user
to specify what the terminating value was, or specify a termination predicate,
but that makes the macro messier. 

When one is writing parsers that actually do input, then the parser is
frequently handed an eof object by its input actions right when it needs one
as its own return value, so things tend to work out -- the eof object sort of
bubbles up through the system. But if you are doing string hacking, then
you've got a problem.

I wish I could be more helpful. I suppose we could advertise a way to access
the eof-object value from S48's internals.
    -Olin

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