[plt-scheme] Doc for "standard peek-char"

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Thu May 17 09:51:41 EDT 2007

SpinyNorman skrev:
> In the MzScheme manual, in Ch11, peek-char is described thus:
> 
> (peek-char [input-port skip-k]) extends the standard peek-char with an
> optional argument (defaulting to 0) that represents the number of
> bytes (not characters) to skip.
> 
> OK, um, where is the *standard* peek-char described?

In R5RS.

http://download.plt-scheme.org/doc/360/html/r5rs/r5rs-Z-H-9.html#%_idx_642

> I'm trying to find out what peek-byte (which is defined by reference
> to peek-char) returns at eof.  

It is returning the end-of-file-object.

> Actually, that's easy to determine
> empirically, but what DrScheme prints, "#<eof>" is not something I can
> test for -- it's a syntax error to write

Which is printed as #<eof>.

> (= "#<eof>" (peek-byte port))

The test is:

   (eof-object? (peek-byte port))

> I understand that I most likely need to use something other than "="
> as well, because I care about equivalence rather than identity.  

Note that = only works on numbers.

-- 
Jens Axel Søgaard



Posted on the users mailing list.