Re: About SUCCESS/FAILURE
| From: | Xinchen Hui | Date: | Wed, 24 Dec 2014 05:18:05 +0000 |
| Subject: | Re: About SUCCESS/FAILURE | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-79908@lists.php.net to get a copy of this message | ||
Hey:
thanks, that is the first thought of mine too.
On Wed, Dec 24, 2014 at 1:06 PM, Andrea Faulds <ajf@ajf.me> wrote:
>
>> On 24 Dec 2014, at 03:25, Xinchen Hui <laruence@php.net> wrote:
>>
>> Hey:
>>
>> We use SUCCESS/FAILURE as return value in some APIs, but use
>> 0/1(false/true) in others.
>>
>> I'd like to remove SUCCESS/FAILURE at all, use 0/1 instead..
>>
>> what do you think?
>>
>> thanks
>
> Hi,
>
> Honestly, I don’t think SUCCESS and FAILURE are bad, they make it explicit that some
> operation is taking place. But using int as the return type seems odd, maybe we could add some zend_
> type for this, maybe an alias of zend_bool?
>
> Similarly, though zend_uchar seems to be what’s used most of the time to store the return
> value of Z_TYPE(), maybe something like zend_type might be good.
>
> In fact, this is exactly what enums do, maybe we should use one:
>
> typedef enum _zend_success {
> FAILURE = 0,
> SUCCESS = 1
> } zend_success;
>
For now, we can not tell what the function return to represent status
from the declaration , since they all return int.
int func();
we have to looks into the source code to get what it used.
so change int func() to zend_success func() may help some bits.
But: return 0 and return FAILURE... which is simpler?
thanks
> Thanks.
> --
> Andrea Faulds
> http://ajf.me/
>
>
>
>
--
Xinchen Hui
@Laruence
http://www.laruence.com/