[ANN] Nile: a trait-based stream library

Andreas Raab andreas.raab at gmx.de
Wed May 2 16:50:42 UTC 2007


Lukas Renggli wrote:
> - The current Squeak Stream implementation lacks the possibility (and
> it is difficult to do so in a clean way) to wrap streams with other
> streams. 

Actually, some streams in Squeak (notably the zip streams) do have that 
ability. Try this for example:

   file := FileStream newFileNamed: 'compressed.gz'.
   encoder := GZipWriteStream on: file.
   encoder nextPutAll: 'Hello World'.
   encoder close. "also closes file"

   file := FileStream readOnlyFileNamed: 'compressed.gz'.
   decoder := GZipReadStream on: file.
   Transcript cr; show: decoder contents.
   decoder close. "also closes file"

As for whether it wouldn't be possible to generalize this cleanly in an 
EncoderStream and a DecoderStream (or a generalized TranscoderStream if 
you like) I'll leave that to the reader. Just keep in mind that if all 
you can think of is using a hammer everything starts looking a *lot* 
like a nail...

Cheers,
   - Andreas



More information about the Squeak-dev mailing list