[Pharo-project] WriteStream strangeness
Hi I have run into two issues when #reset-ing WriteStreams. The first one is that #reset on WriteStream and ReadWriteStream don't have the same semantics [1] (although ReadWriteStream is a subclass of WriteStream). (WriteStream on: String new) nextPutAll: 'the content'; reset; contents gives you '' but (ReadWriteStream on: String new) nextPutAll: 'the content'; reset; contents gives you 'the content' The second is that #reset doesn't affect the answer of #size [2]. WriteStream >> #size has no comment (!) so my naïve assumption of its semantics are: aStream size = aStream contents size However the following test fails: | stream | stream := String new writeStream. self assert: stream size = stream contents size. stream nextPutAll: 'abc'; reset. self assert: stream size = stream contents size [1] http://code.google.com/p/pharo/issues/detail?id=4706 [2] http://code.google.com/p/pharo/issues/detail?id=4707 Cheers Philippe
I don't have a copy of the ANSI standard handy, but I'd be curious whether #reset and #size are already defined in the standard or not... Dale ----- Original Message ----- | From: "Philippe Marschall" <kustos@gmx.net> | To: pharo-project@lists.gforge.inria.fr | Sent: Friday, September 2, 2011 4:08:04 AM | Subject: [Pharo-project] WriteStream strangeness | | Hi | | I have run into two issues when #reset-ing WriteStreams. The first | one | is that #reset on WriteStream and ReadWriteStream don't have the same | semantics [1] (although ReadWriteStream is a subclass of | WriteStream). | | (WriteStream on: String new) | nextPutAll: 'the content'; | reset; | contents | | gives you '' | | but | | (ReadWriteStream on: String new) | nextPutAll: 'the content'; | reset; | contents | | gives you 'the content' | | The second is that #reset doesn't affect the answer of #size [2]. | | WriteStream >> #size has no comment (!) so my naïve assumption of its | semantics are: | | aStream size = aStream contents size | | However the following test fails: | | | stream | | stream := String new writeStream. | self assert: stream size = stream contents size. | stream | nextPutAll: 'abc'; | reset. | self assert: stream size = stream contents size | | | [1] http://code.google.com/p/pharo/issues/detail?id=4706 | [2] http://code.google.com/p/pharo/issues/detail?id=4707 | | Cheers | Philippe | | |
participants (2)
-
Dale Henrichs -
Philippe Marschall