stream.getc() doesn't recognize eof
Brian White
bcwhite at pobox.com
Thu Mar 13 15:25:15 PDT 2008
> Good point, might be safer to check for the 0 return and set c to
> char.init explicitly.
I think it makes a better design. This way feels like relying on
side-effects and I've spent enough time coding perl to know that making
use of side-effects is a great start towards unreadable and
unmaintainable code.
The more obvious you make code, the less likely there will be bugs and
the easier it will be for someone else to maintain it. A comment like
"c still has .init value if readBlock failed" would also be sufficient.
If I were maintaining this code, I would have (wrongly) assumed a bug
and "corrected" it, possibly introducing a new bug.
> (result == 0 && memcmp(buffer_in, buffer, size) == 0));
Eee-Gad, but that's painful! Performance could easily be so bad that
I'd turn off the checks and then they're no use at all.
I've never known a "read" function to modify bytes beyond the "count"
amount returned, but I don't know if it's ever explicitly stated not to
do so.
-- Brian
More information about the Digitalmars-d-learn
mailing list