Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: [BUG?] read-io & write-io or Wait or is TCL better?

From: petr:krenzelok:trz:cz at: 7-Aug-2003 13:19

Gabriele Santilli wrote:
>Hi Petr, > >On Thursday, August 7, 2003, 10:41:04 AM, you wrote: > >PK> request. And why? Because docs don't state that in the case of read-io >PK> we should clear the buffer. If it would lead only to buffer size >PK> increase, then OK, but it leads into completly broken communication with >PK> unexpected results ... > >Actually, you're wrong. First of all, READ-IO and WRITE-IO are >lowlevel functions; >
OK, that is just presumption. Novice user will not know that ... we are here far too long and that is why we remember Holger stating that. But you can bet novice user will do exactly the same bug - will not clear the buffer.
> you should use COPY and INSERT whenever >possible if you don't want to bother with these kind of details. >
I know ;-) Look - I don't have such problems anymore and that is why I also told about the need of buffer clearance to Norman. My aproach is just a bit different - if I can see, that there is some area in which we can see repeated buggy aproach of programmers, we should try to avoid that - either putting it in the doc, or to change behavior. See below ...
>READ-IO and WRITE-IO *DON'T* enlarge the buffer. You have to >provide a large enough buffer for them, and a correct length value >too. Furthermore, READ-IO *DOESN'T* overwrite the buffer you >provide, but instead it appends to it if there is already some >data (this is a useful feature and not a bug). >
Why should read-io "append" to buffer? Would anyone mind if it would simply use preallocated buffer as a storage and used it each time from the head of a series? (kind of a reference word - pointer - to where read-io puts its data). If read-io is said to be low-level, I would expect it more than appending to existing buffer, because, otoh, it does not expand the series and truncates the result, if the buffer is too small - http://www.rebol.com/docs/words/wread-io.html
> For this reason, if >you don't want it do behave this way you have to provide it an >empty buffer. If the docs are not clear about this then this is a >bug in the docs, not in REBOL (Carl is using READ-IO and WRITE-IO >this way so I'm pretty sure it's not a bug ;-). >
I give up ... so we will see new users frustrated each time. They will loose hours of struggling with the code, no matter what me or you think is the correct aproach ...
>What was happening to Norman is that he was resending the first >packet every time. His proxy worked for other services because, by >chance, they didn't happen to send two packets at once. SSH did, >and his code instead of resending the two packets sent the first >two times. > >PK> What do other think? Should write-io clear the buffer after succesfull >PK> write automatically? > >I don't think this would be a great idea, as the buffer could be >needed for something else after the write. For example I may want >to send the data in smaller pieces instead of all at once, so I >don't want the buffer to be cleared as I only send a small part of >it each time. (If you look at the source for async:// you'll see >I'm doing exactly this.) >
You could use another series for its further storage ... :-) -pekr-