On Fri, 31 Jul 2009 02:26:34 -0400, Daniel Keep <daniel.keep.li...@gmail.com> wrote:

Another, somewhat smaller concern, is that the range interface is
back-to-front for IO.

Consider a stream: you don't know if the stream is empty until you
attempt to read past the end of it.  Standard input does this, network
sockets do this... probably others.

But the range interface asks "is this empty?", which you can't answer
until you attempt to read from it.  So to implement .empty for a
hypothetical stdin range, you'd need to try reading past the current
location.  If you get a character, you've just modified the underlying
stream.


These problems have been discussed before, I hope they can be solved. I agree with you that streams do not fit the range interface particularly well, I think the best solution might be to NOT use ranges to implement streams, but allow applying ranges on top of streams for interfacing with other ranges.

Here is one past discussion you may find interesting: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=90971 This is the first posting, but towards the end is where I came to the realization that ranges and streams don't fit together perfectly.

-Steve

Reply via email to