Florian Pflug <fgp@phlo.org> writes:
> On Sep13, 2011, at 15:05 , Aidan Van Dyk wrote:
>> Personally, I'ld think that's ripe for bugs. If the contract is that
>> ret != amount is the "error" case, then don't return -1 for an error
>> *sometimes*.
> Hm, but isn't that how write() works also?
Yeah. It's not possible to maintain the same error-reporting contract
that bare write() has got, unless you're willing to forget about actual
errors reported by a non-first write attempt. Which might not be
totally unreasonable, because presumably something similar is going on
under the hood within write() itself. Most of the errors one might
think are worth reporting would have had to occur on the first write
attempt anyway.
But if you do want to report such errors, I think you have to push the
error reporting logic into the subroutine, which seems a bit messy since
there's quite a variety of error message phrasings out there, all of
which require information that write() itself does not have. Also, we
do *not* want e.g. gettext() to be invoked unless an error actually
occurs and has to be reported.
regards, tom lane