On 03/26/2011 11:11 AM, Paolo Bonzini wrote:

> Yes, your original idea of returning 0 now is correct.  checkError will return
> 0 for you:


What about the following?

> +                    ifFail: [self checkError].

                       ifFail: [SystemExceptions.EndOfStream signalOn: self]


E.g. if I use socket nextLine I will now get a '' as the result that I would
need to handle specially. I am talking to a server right now and I know that
it needs to send 'username: ' right now and my code is doing something like:

[
tmp := socket nextPart. "like nextLine but also checks for $:"
tmp = 'username' ifFalse: [^self error: '']
] on: SystemExceptions.EndOfStream do: [].


With the proposed change to add ifFail: [self checkError] I will now either
need to do:

[
] on: SystemExceptions.EndOfStream do: []
  on: Error do: [].

or

tmp := socket nextPart.
(tmp isEmpty and: [socket atEnd]) ifTrue: [graceful exit]

or move the graceful part into nextLine and nextPart, and would need to
differentiate if nextLine has actually read anything at all.


what do you think?

_______________________________________________
help-smalltalk mailing list
help-smalltalk@gnu.org
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to