[squeak-dev] [ANN] CoroutineReadStream (again)

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Mon Dec 14 20:19:14 UTC 2009


2009/12/14 Stephen Pair <stephen at pairhome.net>:
> On Mon, Dec 14, 2009 at 12:56 PM, Colin Putney <cputney at wiresong.ca> wrote:
>>
>> On 2009-12-13, at 5:22 PM, Stephen Pair wrote:
>>
>> > This version fixes a bug in #close that causes the coroutine to not get
>> > unwound when the stream is closed.  Also, it now uses the stream itself as a
>> > marker instead of a special string (a suggestion from Eliot).  I've also
>> > created unit tests (which is how I caught the problem with close).  Below is
>> > the class comment:
>>
>> Awesome. I've been meaning to implement this for Filesystem. Thanks!
>>
>> Colin
>
> Can you describe how it would be used with Filesystem?
> - Stephen
>
>
>

Maybe an encoder/decoder pattern ?
Example: convert cr-lf pairs to cr only
CoroutineReadStream
	onBlock:
		[ :outputStream |
		[inputStream do: [ :ea |
			outputStream acceptNextObject: ea.
			ea == Character cr ifTrue: [inputStream peekFor: Character lf]]]

Nicolas



More information about the Squeak-dev mailing list