I'd posted a similar message to this on the weekend, but it was a little
sparse on the details, so I'll rephrase it again.

The program I'm writing is passing a ParrotIO object about to various
functions (the ParrotIO object being either stdin or a file handle to a
regular file).  Each function can read as many bytes as it likes from the
descriptor.  There are times, however, where I might decide that I don't
want the byte I just read, and need to push it back onto the stream.  This
brings up (I think) two ways around the problem:

  1) I'd like to be able to peek ahead at a byte, before actually
     consuming it.  ie)

       peek DEST, ParrotIO, NBYTES
       ...
       ...
       read DEST, ParrotIO, NBYTES

     In this case peek returns NBYTES from ParrotIO into DEST, but it's
     not actually until the 'read' op that the bytes are removed.

  2) After reading in a number of bytes from the ParrotIO object, it's
     possible to push it back onto the stream for reading later.  ie)

       read DEST, ParrotIO, NBYTES
       ...
       ...
       unread ParrotIO, BYTES

     Where after the 'read' op I decide that I don't actually want to
     consume the bytes from the strea, so I am able to 'unread' them back
     onto the ParrotIO object.

A Perl 5 module has apparently been implemented with similar behaviour:

  http://search.cpan.org/~bmorrow/IO-Unread-0.03/Unread.pm

So the question remains: are either of these methods possible, planned or
even desirable for Parrot?

Regards,

Cory Spencer

Reply via email to