Operations on file contents should be composable #241
Comments
We already have a proposal for closeable iterators, where the for construct would do what try does today. Sent from my iPhone
|
What @gavinking refers to is ceylon/ceylon-spec#895 |
While I think closeable iterators would work nicely for things like |
What about implementing Iteratees? They are very composable and versatile... Roland
|
@luolong Don't know, reading about them now :) |
Note that while we still haven't properly unified the |
If |
I guess I would prefer to remove |
Well even in the case of |
Well it doesn't offer any such facility now. |
Right now we have a
copyLines()
method which works more or less as amap()
for reading from one file and writing the mapped result to another file.I was thinking about adding something like
filterLines()
where you can decide which lines to copy or leave out.But when I thought about doing something that required both I realized that the current design is not composable at all. We really need a way to access a file's contents like an
Iterable
and have access to all it's useful functionality.The problem of course is that right now
Reader
could not actually be anIterable<String>
because it's assumed that creating anIterator
is cheap and repeatable, which in the case of streams of data might/is not the case.Maybe we need a different Iterable-like interface that implements similar methods for one-shot resource streams. Or maybe the implementation of
Iterable
con be extended to include one-shot resource streams. That should be investigated.The text was updated successfully, but these errors were encountered: