Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79931 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80297 invoked from network); 25 Dec 2014 04:35:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Dec 2014 04:35:06 -0000 Authentication-Results: pb1.pair.com smtp.mail=xinchen.h@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=laruence@php.net; sender-id=unknown Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.215.49 as permitted sender) X-PHP-List-Original-Sender: xinchen.h@zend.com X-Host-Fingerprint: 209.85.215.49 mail-la0-f49.google.com Received: from [209.85.215.49] ([209.85.215.49:57217] helo=mail-la0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 73/51-07310-7F39B945 for ; Wed, 24 Dec 2014 23:35:05 -0500 Received: by mail-la0-f49.google.com with SMTP id hs14so7407701lab.8 for ; Wed, 24 Dec 2014 20:35:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=1/RI/ET6AjBJgyFBdfK483gCsPbgfnhj2SR30nxcGUo=; b=EizrppVCmezolNlcTACFISkVjiyGT9ji717kM6Xdu/FuD/OJ5WCrDCNrL+8dUm4ce/ 1FC+7767xLqcm7ZFGsmVB0cgRjb3o1TmiJIQdY4Pw9RBjkuFYz3ycA6rRa6dG0butWPT ycqG/NL9GCVFL/LoK44wCfbPccYeC/GNYQeoWapHo0b+kn3JXGGyO07d6+Ymm3IFjdf+ 3QQlUAL2RrO+ovCEk9/40YBjBXl/jDpc8sl16+gxynUoU8BOk0RDUjFqyg62h6YjtwfZ hFv/LemVsq3xt5m/QkeWbw7FxiLneWdxHromQtzL/Mvk777vwkTNniiJDhVpfUhDN6xp sehA== X-Gm-Message-State: ALoCoQkH6CTO4+0FMW0GYAnzQPp+EZD7Rc5G7t9CgxwNv4nYpbf9MnFhYPYdyGebbdqYAhCEZQlbj2PPvvvO+U1XkL9yEOHtoU4Qv2hglhim6aNYAMdHhUdwhauPgOaZhdH/P1f/hQoLkk5ffGVyvUMk5GcAT079SA== X-Received: by 10.112.168.164 with SMTP id zx4mr37198559lbb.28.1419482100715; Wed, 24 Dec 2014 20:35:00 -0800 (PST) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPSA id 8sm3238762las.27.2014.12.24.20.34.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 24 Dec 2014 20:34:58 -0800 (PST) Received: by mail-lb0-f181.google.com with SMTP id l4so7577590lbv.12 for ; Wed, 24 Dec 2014 20:34:58 -0800 (PST) X-Received: by 10.112.150.102 with SMTP id uh6mr25274072lbb.66.1419482098396; Wed, 24 Dec 2014 20:34:58 -0800 (PST) MIME-Version: 1.0 Received: by 10.114.64.176 with HTTP; Wed, 24 Dec 2014 20:34:38 -0800 (PST) In-Reply-To: <51160B8D-F662-458E-A0E0-1F37DC3A8869@ajf.me> References: <946C1B1D-30B8-4029-A5A1-73D515A017D8@ajf.me> <1419428487.29904.6.camel@kuechenschabe> <5E26F21C-EA41-43FF-8DDB-D0A985AB4197@ajf.me> <1419463624.28792.6.camel@kuechenschabe> <51160B8D-F662-458E-A0E0-1F37DC3A8869@ajf.me> Date: Thu, 25 Dec 2014 12:34:38 +0800 Message-ID: To: Andrea Faulds Cc: Levi Morrison , =?UTF-8?Q?Johannes_Schl=C3=BCter?= , Pierre Joye , PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] About SUCCESS/FAILURE From: laruence@php.net (Xinchen Hui) Hey: On Thu, Dec 25, 2014 at 12:06 PM, Andrea Faulds wrote: > >> On 24 Dec 2014, at 23:53, Levi Morrison wrote: >> >> On Wed, Dec 24, 2014 at 4:27 PM, Johannes Schl=C3=BCter >> wrote: >>> On Wed, 2014-12-24 at 11:13 -0700, Levi Morrison wrote: >>> >>>> 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. >>> >>> My guess is that positive values more often might have a meaning ("5 >>> items changed", "address 0x1234") whereas negative values less often >>> have a meaning. Also passing -1 as parameter is more often invalid. Thu= s >>> passing -1 is making debug output look more suspicious. >>> >>> (while there are cases where -1 is valid, see recent famous pid >>> =3D fork(); /* ... */ kill(pid, SIGKILL); issue) >> >> I don't think this is the same use case as SUCCESS and FAILURE. Many >> functions have an out parameter which is only valid when the returned >> value is SUCCESS. This is not the same thing as an API which returns >> an integer and just happen to embed error state in the negative range. >> Notably, it doesn't make sense to do `strpos() =3D=3D SUCCESS` to check >> success; these are different cases. My question is specifically >> directed at the ones that use SUCCESS and FAILURE: which ones require >> FAILURE to be negative instead of the normal UNIX-ism of non-zero? >> >> For the record I am in favor of an enum such as `zend_status` or some >> other name which indicates whether an operation succeeded or not for >> the reasons already cited in this thread. I just don't see why FAILURE >> needs to be negative and want to know why this is the case. > > Hi Levi, > > Again, I think the reason FAILURE is -1 is for consistency with other fun= ctions which use negative return values on error. Some functions return neg= ative error codes, others just -1. Some functions return useful positive va= lues, others just 0. But the idea is that all functions return a negative n= umber on error, so you can use if (foo() < 0) to check for errors. That=E2= =80=99s the point of making FAILURE be -1, AIUI. It makes it consistent wit= h other things, like fork() or strpos(). > > Thanks. lets make this simple. first we need unify PHP self.. thanks > > -- > Andrea Faulds > http://ajf.me/ > > > > --=20 Xinchen Hui @Laruence http://www.laruence.com/