[Ann] Nile 0.8.0 available
Damien Cassou
damien.cassou at gmail.com
Fri May 11 10:35:26 UTC 2007
I've just released a new version of Nile, a completely new stream
implementation.
It's available on Universe (category 'Model Extension'), SqueakMap and
SqueakSouce (loads Nile-All from http://www.squeaksource.com/Nile).
Nile already allowed you to stream over readable collections and
writeable collections. This part has been enhanced with more tests and
more functionalities. A diagram can be seen at:
http://damien.cassou.free.fr/documents/internship_2007/nile/complete_hierarchy.pdf.
But now, Nile is able to read from and write to files too (thanks to
Mathieu Suen for the implementation). A diagram is available at:
http://damien.cassou.free.fr/documents/internship_2007/nile/fileStreams.pdf.
You can also use Nile in a pipe-like way: you can chain different
streams to obtain a bigger, more interesting stream. For example:
| stream |
stream := ReadableCollectionStream on: '123 12 142 25'.
stream := NumberReader inputStream: stream.
stream := SelectStream selectBlock: [:each | each even] inputStream: stream.
stream peek. ==> 12
stream next. ==> 12
stream atEnd. ==> false
stream next. ==> 142
stream atEnd. ==> true
This code uses three stream:
- NSReadableCollectionStream is equivalent to ReadStream.
- NSNumberReader is waiting for characters on its input and converts
them to numbers. Spaces separate numbers.
- NSSelectStream reads its input and only returns elements matching
the selectBlock (http://wiki.cs.uiuc.edu/PatternStories/SelectStream)
Each pipe is really easy to implement: subclass a particular class and
implement a method and a constructor.
What is your opinion about this work?
--
Damien Cassou
More information about the Squeak-dev
mailing list
|