Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119575 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 28870 invoked from network); 19 Feb 2023 08:45:36 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Feb 2023 08:45:36 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C1DE0180504 for ; Sun, 19 Feb 2023 00:45:35 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 19 Feb 2023 00:45:35 -0800 (PST) Received: by mail-qt1-f182.google.com with SMTP id i5so222856qtw.6 for ; Sun, 19 Feb 2023 00:45:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:cc:to:from:date:references:in-reply-to:message-id :mime-version:user-agent:feedback-id:from:to:cc:subject:date :message-id:reply-to; bh=xfe+BvEXva6rvnARc5W0IfqzzKsJm7hjuBozosbA9pM=; b=XH8D6Myeb/tbQH8BP+SAhWIYRyZUaS22qMFPpsKj+7XZkqPgLWIVEWZ2LcnmEG2wBs qpH7dEJ4SiacKIKtta+tyggLoeXgFRw9XoHfFvnJBoFP33m3WJx8247b2nP5N/ZQ+95H /Ck6IHSnJEvrvDQ2dFm9XJHfJhvR2MpJqQCgitutxHqRGDjWdNdbwUASNVJGKqzWEyDg FDae4ye1aiqpKgW2ZVFWo2ZfgwVR1fdnjj130627TeeF5dAvQ7kkpwtW4ci6jQoZYWNQ ak2Pd81y+W8fLRYw90W5ic3E2JHtou0mLhMQgACk+CoWouXXcMCUkopHtGMMUDbiDpip nylA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=subject:cc:to:from:date:references:in-reply-to:message-id :mime-version:user-agent:feedback-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xfe+BvEXva6rvnARc5W0IfqzzKsJm7hjuBozosbA9pM=; b=eFqVXZLTzMhZimJjPelvDmJzeuDsGX3gVuE5jUHVorAK2XJsOyo91zGCqIex4g8/zH RwjL9AWqzhg2MwWs3iAJjjHo6c0CNkCtJi9RJh8Ueh31nxRh73dEhmjIzIQo8Q/T0HOz BkHwqL7T2DvZuBLzNyX4niwV3e5VZaw35v81kTP/H3cNJRwz93f8sX4kpPcGV+Vcf8Bg /6ho3EFh/P83G9K3nIcoKsWuemCOtIz9RoikodlCfQ0bz25wBE7hTNqXuOibBB2FYlRJ TxfAGyFOmuVVGb7ZyIY9QycX2DO/HKaRxtGsPFkEIdNm0rnsHISFBQuqKYoe6EMP5G4s 1XUg== X-Gm-Message-State: AO0yUKWyFUkfSjIae7NFIkUG6zdUdDvpSi/upuEVVYXANw2EH2ib8YhX 336Y8W2Wx0SRCHAuVlwW3JpDnMvbck8= X-Google-Smtp-Source: AK7set9lOf5t4Lmd/JgYHFOSc1x+ZZEsi0fkFL2Z3FUN5IVROqdc12wt3cZ1SOcNJnzQUaJ8CT3+0g== X-Received: by 2002:ac8:5b81:0:b0:3b8:5f47:aac2 with SMTP id a1-20020ac85b81000000b003b85f47aac2mr13724924qta.1.1676796334573; Sun, 19 Feb 2023 00:45:34 -0800 (PST) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com. [66.111.4.228]) by smtp.gmail.com with ESMTPSA id p4-20020a05622a00c400b003b68d445654sm6757417qtw.91.2023.02.19.00.45.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Feb 2023 00:45:33 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id 9E87127C0054; Sun, 19 Feb 2023 03:45:33 -0500 (EST) Received: from imap48 ([10.202.2.98]) by compute2.internal (MEProxy); Sun, 19 Feb 2023 03:45:33 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudejvddguddvvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvfevufgtse grtderreerredtnecuhfhrohhmpedfpfhikhhithgrucfrohhpohhvfdcuoehnihhkihht rgdrphhpvhesghhmrghilhdrtghomheqnecuggftrfgrthhtvghrnhepvedvgeefleeiue dugeeguedugeduveeikeevgeegieekleegiedujeejgfeftdetnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhgrihhlodhmvghsmhhtphgruh hthhhpvghrshhonhgrlhhithihqddufedufeeludekheeiqddvheekvdegheeikedqnhhi khhithgrrdhpphhvpeepghhmrghilhdrtghomhesnhhpohhpohhvrdgtohhm X-ME-Proxy: Feedback-ID: id4a9467a:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 6F12D31A0063; Sun, 19 Feb 2023 03:45:33 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-156-g081acc5ed5-fm-20230206.001-g081acc5e Mime-Version: 1.0 Message-ID: <478d639f-9f09-4747-a21a-eb4bceb5c053@app.fastmail.com> In-Reply-To: References: Date: Sun, 19 Feb 2023 09:45:09 +0100 To: "Max Kellermann" Cc: "Levi Morrison" Content-Type: multipart/alternative; boundary=a7c62038007c4afb841782d250cce9cf Subject: Re: [PHP-DEV] What's the purpose of zend_result? From: nikita.ppv@gmail.com ("Nikita Popov") --a7c62038007c4afb841782d250cce9cf Content-Type: text/plain On Sun, Feb 19, 2023, at 09:21, Max Kellermann wrote: > On 2023/02/19 08:56, Nikita Popov wrote: > > If you have a function like zend_stream_open_function(), SUCCESS and FAILURE are directly meaningful values. > > Agree, but that doesn't explain why FAILURE needs to be negative. I expect that there are two main reasons for that: - There are probably some places that return a (non-negative) value or FAILURE. - There are probably some places that check for success/failure using >= 0 and < 0. Another POSIX-ism. I don't think we endorse such usage, but it likely exists. Let me turn the question around: Is there some reason to change the value of FAILURE at this point? > > The current guideline for use of bool and zend_result in php-src is that bool is an appropriate return value for "is" or "has" style functions, which return a yes/no answer. zend_result is an appropriate return value for functions that perform some operation that may succeed or fail. > > What does the return value of these functions mean? > > - zend_make_printable_zval() > - zend_make_callable() > - zend_parse_arg_bool() > - zend_fiber_init_context() > - zend_observer_remove_begin_handler() > - php_execute_script()1 > > If I understand the guideline correctly, then those examples (and > countless others) are defective and should be fixed, correct? At least in principle, yes. Of course, actually doing a change may not always be worthwhile, especially as this might result in a silent behavior change for extensions (as putting the return value into an "if" would invert behavior now). I believe Girgias has done extensive work on making the int vs bool vs zend_result situation more consistent, so you might want to coordinate with him. Regards, Nikita --a7c62038007c4afb841782d250cce9cf--