Re: [Pharo-project] peek and friends
thanks! On Jan 30, 2010, at 9:23 AM, Igor Stasenko wrote: > On 29 January 2010 23:09, stephane ducasse wrote: >> hi Igor >> >> finally should I integrate >>http://bugs.squeak.org/view.php?id=7446 ? >> I was waiting because you said you were confused >> > > Yes, integrate that, since it deals with issue that #peek should > answer the same byte as following #next. > > We turned discussion into other issues, not related to this _bug_ (but > related to #peek behavior), concerning what will happen if timeout > appear. Here the last version(s) of both peek and next which taking > care about it: > > > !SocketStream methodsFor: 'stream in' stamp: 'Igor.Stasenko 1/15/2010 02:02'! > next > "Return next byte, if inBuffer is empty > we recieve some more data and try again." > > [self isDataAvailable] whileFalse: [ > self receiveData. self atEnd ifTrue: [ ^ nil ]]. > > ^inBuffer at: (lastRead := lastRead + 1) > ! ! > > !SocketStream methodsFor: 'stream in' stamp: 'Igor.Stasenko 1/15/2010 01:33'! > peek > "Return next byte, if inBuffer is empty > we recieve some more data and try again. > Do not consume the byte." > > [self isDataAvailable] whileFalse: [ > self receiveData. self atEnd ifTrue: [ ^ nil ]]. > > ^inBuffer at: lastRead +1! ! > > > As you can see, the only difference between peek and next is that one > advancing the buffer pointer, while other not. > >> Stef >> >> ___ >> Pharo-project mailing list >> Pharo-project@lists.gforge.inria.fr >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> > > > > -- > Best regards, > Igor Stasenko AKA sig. > > ___ > Pharo-project mailing list > Pharo-project@lists.gforge.inria.fr > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project ___ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Re: [Pharo-project] peek and friends
On 29 January 2010 23:09, stephane ducasse wrote: > hi Igor > > finally should I integrate > http://bugs.squeak.org/view.php?id=7446 ? > I was waiting because you said you were confused > Yes, integrate that, since it deals with issue that #peek should answer the same byte as following #next. We turned discussion into other issues, not related to this _bug_ (but related to #peek behavior), concerning what will happen if timeout appear. Here the last version(s) of both peek and next which taking care about it: !SocketStream methodsFor: 'stream in' stamp: 'Igor.Stasenko 1/15/2010 02:02'! next "Return next byte, if inBuffer is empty we recieve some more data and try again." [self isDataAvailable] whileFalse: [ self receiveData. self atEnd ifTrue: [ ^ nil ]]. ^inBuffer at: (lastRead := lastRead + 1) ! ! !SocketStream methodsFor: 'stream in' stamp: 'Igor.Stasenko 1/15/2010 01:33'! peek "Return next byte, if inBuffer is empty we recieve some more data and try again. Do not consume the byte." [self isDataAvailable] whileFalse: [ self receiveData. self atEnd ifTrue: [ ^ nil ]]. ^inBuffer at: lastRead +1! ! As you can see, the only difference between peek and next is that one advancing the buffer pointer, while other not. > Stef > > ___ > Pharo-project mailing list > Pharo-project@lists.gforge.inria.fr > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > -- Best regards, Igor Stasenko AKA sig. ___ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
[Pharo-project] peek and friends
hi Igor finally should I integrate http://bugs.squeak.org/view.php?id=7446 ? I was waiting because you said you were confused Stef ___ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project