On Mon, Jun 8, 2009 at 6:00 PM, Nicolas Cellier<nicolas.cellier.aka.nice@gmail.com> wrote:
2009/6/8 Damien Cassou <damien.cassou@gmail.com>:
On Sun, Jun 7, 2009 at 2:15 AM, Nicolas Cellier<nicolas.cellier.aka.nice@gmail.com> wrote:
Before adding a new set of messages, why not make the endOfStream pluggable?
I'm not sure it will work because different methods will expect different behavior. Thus these methods won't be able to communicate with the same stream.
I see what you mean, Stream internally use endOfStream handling for implementing some of its protocol and must therefore know whether an endOfStream event will return nil or raise an Exception, is that it?
Yes
Messages that use construct like: Â Â [self atEnd] whileFalse: [...] should always work.
Yes
Messages that use constructs like: Â Â [(char := stream next) ~~ nil] whileTrue: [...] could eventually be written: Â Â | oldEndOfStream | Â Â oldEndOfStream := endOfStream. Â Â [[(char := stream next) ~~ nil] whileTrue: [...]] Â Â Â Â ensure: [endOfStream := oldEndOfStream].
better: stream do: [:char | ...] which is a good refactoring in all cases, even without the proposed changed I guess. -- Damien Cassou http://damiencassou.seasidehosting.st "Lambdas are relegated to relative obscurity until Java makes them popular by not having them." James Iry