Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

for 1, the consumer is properly the user not the programmer.. and the user cannot ignore the error string in favour of the number if the programmer provided only that. Since the documentation specifies the error strings,

for 2, the function can be called (as can any C function) from a source character set other than ASCII, as the compiler should handle that. The name is technically english its true and programmer needs to know some english, perhaps.. but the user does not need to know that

if the error code is used, then the error string is superfluous, and C library functions are not in the habit of providing superfluous information. C is pretty low level after all.

Here is more reading about the objections the NetBSD folk had with strtonum(3)

  http://mailing.netbsd.tech.userlevel.narkive.com/mZ37nlai/strtonum-3-from-openbsd


Still confused.

What is a user in your reply? I mean, an end user / my mom isn't going to call strtonum? Some developer does. And said developer can absolutely ignore the string's content?

Test for success: errno is 0, errstrp is NULL Handle error: Use errno or errstrp - the latter gives you a bit more information (reports a different error for invalid ranges, too small vs. too large).

But if you don't care, errno is fine, no? And we're still talking about the programmer here, as far as I'm concerned.

Ted has a description of his intentions here [1]. I guess I'm confused why there's a fuzz about it, because technically this method should be good enough? I do have to shake my head at the "Even if intmax_t probably would have been a better choice, I think we’re sticking with long long just because it frustrates people unwilling to admit it doesn’t make a difference." remark, but .. other than that? Does it .. matter?

1: http://www.tedunangst.com/flak/post/the-design-of-strtonum


Yes, the user is the person who runs the program that they didn't write. They don't know that they called strtonum()

testing for errno == 0 is not actually useful, since errno is not set except on error (that is by design of errno, it is always an indication of what the last error was, not that there was an error)

and errstrp doesn't give the Klingon user you mentioned any information at all, since they can't read English.

fafner said it better than I in https://news.ycombinator.com/item?id=9184734

and yes it does matter, for a standard libc function, because if you don't take care about setting standards, then your standards will be a mess.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: