From: David M. <Dav...@de...> - 2002-08-02 13:04:27
|
I've been having another look at the Basis library implementation in=20 Poly/ML and in particular the I/O library. I'm still not sure I fully=20= understand the implications of the Stream IO (functional IO) layer and=20= in particular the way "canInput" works and interacts with "input". The definition says that canInput(f, n) returns SOME k "if a call to=20 input would return immediately with at least k characters". =20 Specifically it does not say "if a call to inputN(f, k) would return=20 immediately". Secondly it says that it "should attempt to return as=20 large a k as possible" and gives the example of a buffer containing 10=20= characters with the user calling canInput(f, 15). This suggests that a=20= call to canInput could have the effect of committing the stream since a=20= perfectly good implementation of "input" would be to return what was=20 left of the buffer, i.e. 10 characters, and only read from the=20 underlying stream on a subsequent call to "input". Yet after a call to=20= canInput(f, 15) which returns SOME 15 the call to "input" is forced to=20= return at least 15. In other words a call to canInput changes the=20 behaviour of a subsequent call to "input". Generally, what is the=20 behaviour of canInput with an argument larger than the buffer size? How=20= far ahead is canInput expected to read? A few other notes of things I've discovered, some of which are trivial: The signature for TextIO.StreamIO contains duplicates of =A0=A0where=A0type=A0StreamIO.reader=A0=3D=A0TextPrimIO.reader =A0=A0where=A0type=A0StreamIO.writer=A0=3D=A0TextPrimIO.writer There are declared constants for platformWin32Windows2000 and=20 platformWin32WindowsXP in the Windows structure. When I proposed the=20 Windows.Config structure I didn't include constants for these versions=20= of the OS because the underlying GetVersionEx function returns the same=20= value, VER_PLATFORM_WIN32_NT in the dwPlatformId field for NT, Windows=20= 2000 and XP It is possible to distinguish these but only using the=20 major and minor version fields. Windows CE does give a different value=20= for the platformID. I would say it is confusing to have these here=20 because it implies that it's possible to discriminate on the basis of=20 the platformID field. The example definition of input1 at the bottom of STREAM_IO returns a=20 value of type elem option * instream when the signature says it should=20= be (elem * instream) option. Description of "input" function in STREAM_IO signature. The word "ay"=20= should be "may". -- David. |