From: Nicolas C. <war...@fr...> - 2004-01-26 12:12:33
|
> Note that I suggested seek only for input streams. > > If I understand the interface correctly an object of type ('a, 'b) input > semantically corresponds to a list of objects of type 'a with one > selected position (the current one). Therefore, the semantics of seek > and pos should be: > > If "in" corresponds to the list a_0,...,a_n and a_i is the currently > selected element, then "pos in" should return i and "seek in k" should > mark a_k as new selected element. The only problem I see is that doesn't scale well with strings. As I show you before, you might consider strings as N-char-lists, but the semantics of reading depends for example if the file is open in binary of text mode. Other case : if you have a file containing N strings of X characters separated by \0 , then reading 3 strings will give you a position of 3*(X+1) - including the \0 separator. It's difficult to add a concept of "length" and "pos" on such tokens , although it's very easy to do in the case ('a,'a list) input. Regards, Nicolas Cannasse |