Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126094 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 7E7721A00BD for ; Mon, 2 Dec 2024 15:13:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1733152199; bh=x7R3OdXepeY2wyOP6VhGkkJbNueV63e9EWt1OGINwS4=; h=From:Subject:Date:References:To:In-Reply-To:From; b=gaD69Rv/HN639Yi0ga2qSD4N56y0QdHxSIFJt8ZWGk26T2KinMhmL16/n2TIe0e7H 469KPh7HLYfsgWDa7hYpZykSXGe3dPHJqHKFEVockXdXhHMd0W7b/iBAJA67y9i5Bz aC9rykwNpp9zQut8FtA+3+m/LmUNhB0iV0Et7SY8WyWOd6JiKinGnYF32uJHYgDlDT 0N8cD9yWhu03Uxkf98egUwkEVwnwZiHwIvvfIbYmlG2w9TaR8q6Xzfdx1QBjBcggCy fuVAaCPp3mzimjrENydGW5Jvigv5i2U3hx70xh25vcEbzDPb5v7ZYOMGxArJYYvO2v u+TEX5zqDO9Rw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 15FE718002F for ; Mon, 2 Dec 2024 15:09:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail.gna.ch (mail.gna.ch [212.45.196.109]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 2 Dec 2024 15:09:57 +0000 (UTC) Received: from smtpclient.apple (unknown [194.169.219.181]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by darkcity.gna.ch (Postfix) with ESMTPSA id 10F9A3A1183 for ; Mon, 02 Dec 2024 16:13:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=cschneid.com; s=default; t=1733152384; bh=x7R3OdXepeY2wyOP6VhGkkJbNueV63e9EWt1OGINwS4=; h=From:Subject:Date:References:To:In-Reply-To; b=W7s8Dx814b4V+1KY3znaKDDn3yikYzIFXHb9N3Q1srNwpM1GN5UpihjCoK8tvWhWr UP/5DYgr+9ZXixpwpgKWts6qTRpeiwZGBL9EQawhEcns0rHmKku9UheUbUnxI+1mdu acWpT5KAuKCYLVoF42E9zfpG1G3JGCQ1/TT51wMs= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.200.121\)) Subject: Re: [PHP-DEV] Inaccurate documentation on return values from native functions Date: Mon, 2 Dec 2024 16:13:03 +0100 References: To: internals@lists.php.net In-Reply-To: Message-ID: <0FAE2A45-A1CE-4D2B-A6AC-82CF40CE8EAD@cschneid.com> X-Mailer: Apple Mail (2.3826.200.121) From: cschneid@cschneid.com (Christian Schneider) Am 02.12.2024 um 13:31 schrieb Rowan Tommins [IMSoP] = : > On 01/12/2024 23:50, mickmackusa wrote: >> I can appreciate that. Going forward, is there any benefit to = preserving the behavior of returning integers beyond -1, 0, and 1? >> Should these topically related functions receive a new last argument? = bool $distance =3D false >=20 >=20 > The functions are not attempting to return a meaningful "distance", = this is just an optimisation: the intended use case is as a callback to = functions like usort() which only care about <0, 0, >0, so no CPU time = is spent normalising the result to specific values. > The documentation is simply mistaken in saying "-1" instead of "a = value less than zero" and "1" instead of "a value more than zero". After following the discussion I am a bit unsure what the conclusion is: a) We should keep it as is (but change the docs) because of BC b) We should keep it as is (but change the docs) because it prevents = people from relying on -1 and +1 c) We should consider changing it to -1 and +1 for consistency and = something like 'switch/case' uses It looks like the general opinion seems to be a) or b) but I still = wanted to double-check. PS: I have a local branch with the necessary changes to code and tests = and performance is not impacted negatively. I could turn it into a PR if = wished. Regards, - Chris