Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126093 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 674BE1A00BD for ; Mon, 2 Dec 2024 12:31:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1733142501; bh=/Fa64h1a8xpXgFkw98/iqNQe/3r08GF7wouGEKAzdUc=; h=Date:Subject:To:References:From:In-Reply-To:From; b=eCnglMJ06bzCQsVmRhZjP9c8URNDj82MWOdsKx0V/oCBJTkaW4VcNAydVcR9XU2QI merAZH+psQx8xJDcHy2F52SwMlMBQ9GxHCGcWgW/0DksKF2FNXLmZ2laOIZ0k6c23q LzpbEaQqM74DeaUrQtFDL+h+UX3zKZCQYSfuUrVNedIZ17ngbuML2j/tsq4T0h7FxN WLpbDkNedzynCXRfKWPcHBgrvGWqdxPq9dVUrdhn5ug4JnoIkuN2RVKQLnSR/xfkW/ LUUVz3gIddZu9rdGLcvnleXyy85B7ITCDTVkOmAZBGumJ6WUT32Z5QG472+OT5lp7N CDrO7CfaXNFWg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 74165180042 for ; Mon, 2 Dec 2024 12:28:20 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (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 12:28:19 +0000 (UTC) Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfhigh.phl.internal (Postfix) with ESMTP id 94702114015E for ; Mon, 2 Dec 2024 07:31:27 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Mon, 02 Dec 2024 07:31:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1733142687; x=1733229087; bh=VsU/X6jQAz pWSsI9jkOMcAIu7e7s58Xq7OWb1Z45YNM=; b=WUJ5TydBvdMgFn761fnx8p8SGF ZPewz402a8iJL0Lt7RIi8sk1np3q/suzhVPCkPKEbea0OrT19csSIlvMhI7Xv71/ 98MvG3aeD0Iy2mQ6W3uPrw/BoRwBIV7q+o5dNVy6dNGcjil6FFuFQVNmT0mbWTxw x9kBLwOKNA2KLRo89m6Ycet9ok43fJ3AAHrXV9AUlss0TSV+rENjawCzngIs/VEl XorLqw7T4lPou6bVq1zmnW1D/6TtInHmIGaRGZNHkDKnh5hCtCY9KSONdXis4+5H JXeLJC4XEhOjQ4GeK4TT7PRKTZRzMR/6tAdwdoAmPTScmPT/MYJCxJmtSr7A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1733142687; x=1733229087; bh=VsU/X6jQAzpWSsI9jkOMcAIu7e7s58Xq7OW b1Z45YNM=; b=l2FGNf/BIkjWvfoVAszeRURG7FzeHe0ME8gRSsYKRXpeUI73b7W 75FJP+QNJpl16gS+4NRUeNZTt772h9DjqFWfTw4NQ7QDJb1N0x1GZRZ/CDMODIMP NtMEi3C8l2IuhuiFh0/S4ahfZtFmyfYQk0V37zQtC7mM7lKz5XE7E+ueXxJicHlF uoWY84T9YooHOYkWFf1KpPMCgm/hquaDq91O8gkQwBZsDH83AoGh4qyBJVEvx5Kl i7Xytb+rrT9c2Ju40Rxg0Z7taCBAZieInafF7RBYw992POueAXQqwMsSjjLXX1Fb g0SBubn7D0NY9calQlYpZV2b499s4KL3jgA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrheelgdeflecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurheptgfkffggfg fuvfhfhfgjsegrtderredtvdejnecuhfhrohhmpedftfhofigrnhcuvfhomhhmihhnshcu lgfkoffuohfrngdfuceoihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqeenucggtf frrghtthgvrhhnpeegtdffhfdtjefhuddtuddvkeejteeguddtkeeghfeigeejudevhffg gfevtddtjeenucffohhmrghinhepshhtrggtkhhovhgvrhhflhhofidrtghomhdpvgigth gvrhhnrghlshdrihhonecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomhepihhmshhophdrphhhphesrhifvggtrdgtohdruhhkpdhnsggprhgtphhtth hopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhssehl ihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Mon, 2 Dec 2024 07:31:26 -0500 (EST) Content-Type: multipart/alternative; boundary="------------80sZSiRcaVkOIGvQDO0jlzUl" Message-ID: Date: Mon, 2 Dec 2024 12:31:24 +0000 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] Re: Inaccurate documentation on return values from native functions To: internals@lists.php.net References: Content-Language: en-GB In-Reply-To: From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") This is a multi-part message in MIME format. --------------80sZSiRcaVkOIGvQDO0jlzUl Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 01/12/2024 03:41, mickmackusa wrote: > [image: image.png] Please avoid images of text; most of the reasons it's a bad idea on Stack Overflow apply here https://meta.stackoverflow.com/q/285551/157957 plus a lot of mailing list archives and e-mail readers will not show HTML formatting at all, e.g. https://externals.io/message/126085 I had to read several replies to actually see what issue you were discussing. 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 = false 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". Regards, -- Rowan Tommins [IMSoP] --------------80sZSiRcaVkOIGvQDO0jlzUl Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 01/12/2024 03:41, mickmackusa wrote:
[image: image.png]


Please avoid images of text; most of the reasons it's a bad idea on Stack Overflow apply here https://meta.stackoverflow.com/q/285551/157957 plus a lot of mailing list archives and e-mail readers will not show HTML formatting at all, e.g. https://externals.io/message/126085

I had to read several replies to actually see what issue you were discussing.


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 = false


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".

Regards,

-- 
Rowan Tommins
[IMSoP]
--------------80sZSiRcaVkOIGvQDO0jlzUl--