> On 24 Dec 2014, at 18:13, Levi Morrison <le...@php.net> wrote: > > On Wed, Dec 24, 2014 at 10:34 AM, Andrea Faulds <a...@ajf.me> wrote: >> >>> On 24 Dec 2014, at 17:22, Levi Morrison <le...@php.net> wrote: >>> >>> Hmm. This thread doesn't seem to mention it, but why must failure be >>> negative? I understand the non-zero part but not negative. Aside from >>> the fact we probably have code relying on it to be negative at this >>> point is there some other reason? >> >> Hey Levi, >> >> I believe it's a convention among C APIs: 0 for success, negative for some >> error > > I'm asking for specific things. The reason is that some API's do a > non-zero error code; the fact that they are negative is a detail that > we should not need to care about.
Actually, that email was cut off: unfortunately iOS doesn’t require confirmation to send an email and my finger slipped. The main point of negative values AIUI, is that you can return useful information for positive or zero values and error codes for negative values. For example with strpos(). For some APIs you only need 0 and -1, mind you, but being able to do if (foo() < 0) for everything is pretty neat. -- Andrea Faulds http://ajf.me/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php