[MLton-devel] Basis2002: IO
Matthew Fluet
fluet@CS.Cornell.EDU
Sun, 27 Oct 2002 09:55:54 -0500 (EST)
> Does the imperative level have something that lets you un-get characters. Once
> you have that you can do pretty much everything, but without it you are kind of
> stuck. (You can handle things as long as only one piece of code is doing the
> reading, but otherwise you are pimped even inputing things like integers
> without at least one character of look-ahead or un-getting.)
We don't have anything less (or significantly more) for IO than we have in
the main branch/release. So, we have:
val lookahead: instream -> elem option
determines whether one element is available on strm before
end-of-stream and returns SOME e in this case; returns NONE if at
end-of-stream. In the former case, e is not removed from strm but stays
available for further input operations. May block, and may raise the
exception Io.
That gets you one character of lookahead. It's followed by the comment:
Note that arbitrary lookahead can be easily implemented using the
underlying stream.
In our case, the caveat is that when you drop down to the underlying
stream, you'll pay for it in performance.
There is nothing at the imperative level that let's you push elements back
onto the input stream. If you drop through the stream io level and
extract the primitive reader, when you come back up and
StreamIO.mkInstream the reader, you have the opportunity to pass the
initial input buffer, which gives you a method of pushing elements back,
but it would be fairly expensive.
-------------------------------------------------------
This SF.net email is sponsored by: ApacheCon, November 18-21 in
Las Vegas (supported by COMDEX), the only Apache event to be
fully supported by the ASF. http://www.apachecon.com
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel