Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126095 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 C7AD21A00BD for ; Mon, 2 Dec 2024 16:12:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1733155760; bh=ESq6LiVZdektjvWXRyFfdLU53501lXPGUmI6SZp72yQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ZwEB5gkkAZPRLPj+yU8cKrUXSFobPhrfzrG57DXA3IMItQfoNNj9XOLN+zqCSXPZr W2YVjGhgSZCbX2eehKM66gZUI6rGkAcdQKKopJqHghTWlNwgunFNP7qGF5JFz8cFnz x9Khn1lUBvr2/9kmkyZ46sEdP+Vft5oyu1qduDgjd3MeYCesLmKpd0dCgukObu2frM iXNWbZprZfPv1mSaNU6lK/iLOBy3zFRJsozyVLR9pvLMbsBGI3uZjCqcr+adCoUyZf EG56FowEBgQ1KsDnSzmjQmGMGjcunopGibZ0skwdMx1TWyOObnrM8Fdw30iW3biRR0 u6i9I6U8IQXWA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2B213180047 for ; Mon, 2 Dec 2024 16:09:19 +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.9 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) (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 16:09:18 +0000 (UTC) Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-288fa5ce8f0so1774165fac.3 for ; Mon, 02 Dec 2024 08:12:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733155946; x=1733760746; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=fOKvOm8odMdtOmto0KQLfwKt0TyWE7X+vyf4QvHOj48=; b=fLQ03vSRz9hqmBzg54ezre8WsJW2+Hw8tNW9LsOTXlk9lofCy0jyLr3s69h0MCRxT6 sf4IbPdXNOxwGt9fa5l+S5Ip7vLXWj6cZ3jB1N0wZPKBIrA1CHfMxlOu6htXXzMrWYTo uTnDuaizYLvtitAvfD0Fmd19APxC9LlvGen5rTOEjLR4dPkZrCb/Mg4/XwVGwHWUwEGE ogWIQGr9KHgK7GBFVkSHsMFWp6qBZhZhSBojFUzklELrevJ5xnfpd3gsJ/jzlPmroQMN IGgC78AS+nvm6syyZmiY9PHc+KVJAzUqolUx1qhDkA9pcQPLY3j1LrW6KXArHq0ylxU6 tbqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733155946; x=1733760746; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fOKvOm8odMdtOmto0KQLfwKt0TyWE7X+vyf4QvHOj48=; b=Unc4E69likmXCs8qtmXoiWv08fwlyDb6PFHQlN5a+Z2eAzhCkYPCethrZA5kqL0xqJ ksnrzQN7//SUl0tvIg84X/v+WtVrHmzExn2lKRF4B7C9xLJSAM3ADxuYPQV58oQdgih/ PqOpC/CzxMenrorEXfesqNibQYrBisOnv1xpaNpSgaMyMgP/IL3x/k57ocrp+7yM7qWr K0mRm8lAsYtaHJGrfX4YEjrv4BpZRdY/6zaWHnTGfLtU7Q5N0RcwhIlk0UDC5XBnO5x1 wZ8Uos1VQLjsUyQCVHAOgyGn9LpbzSIXESi91G3uAScNhBDWrL5KZJqe8wX0rA8ptF8E DApw== X-Gm-Message-State: AOJu0YwliTOciOLJYBHHhXOFxoSjLPo6cP4Epbl7gwMoCp7zVVf+4+fM v5lkEC8VizXYaccRxvHQ9h7/nVM9nhKB202ey1VAda6WuJ1/WRPhOyswgexJx6b5o3BS8hsJUsI bAIGMMmkfR5xzQhVCqxxTsSaLYhtqfqWQ X-Gm-Gg: ASbGncursUXjuttckdzOR8+FKlvCGhI4KrGxHcIa1XQIt6MCDWJBaCev6p6/hB0dWql vfJflv9ZTYnuGPrFYc53aYk1zv3HiPr4= X-Google-Smtp-Source: AGHT+IG1LkJ88kknIDAYJkWY0t6Aq0A3L27XUDOL1ZBMFsYBIwLHZs6TZzvP8fjaYaCDkz/qd5zU7q1/dLa6WTPnN08= X-Received: by 2002:a05:6870:ad0d:b0:29e:40f8:ad9b with SMTP id 586e51a60fabf-29e40f91883mr6287255fac.14.1733155944892; Mon, 02 Dec 2024 08:12:24 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <0FAE2A45-A1CE-4D2B-A6AC-82CF40CE8EAD@cschneid.com> In-Reply-To: <0FAE2A45-A1CE-4D2B-A6AC-82CF40CE8EAD@cschneid.com> Date: Mon, 2 Dec 2024 17:11:48 +0100 Message-ID: Subject: Re: [PHP-DEV] Inaccurate documentation on return values from native functions To: Christian Schneider Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: divinity76@gmail.com (Hans Henrik Bergan) On Mon, 2 Dec 2024 at 16:16, Christian Schneider wr= ote: > > 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 preserv= ing the behavior of returning integers beyond -1, 0, and 1? > >> Should these topically related functions receive a new last argument? = bool $distance =3D false > > > > > > The functions are not attempting to return a meaningful "distance", thi= s is just an optimisation: the intended use case is as a callback to functi= ons like usort() which only care about <0, 0, >0, so no CPU time is spent n= ormalising 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 peop= le from relying on -1 and +1 > c) We should consider changing it to -1 and +1 for consistency and someth= ing 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 an= d performance is not impacted negatively. I could turn it into a PR if wish= ed. > > Regards, > - Chris I vote A