Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123164 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 003A21A009C for ; Fri, 19 Apr 2024 21:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1713562202; bh=wVpLbNjZD/BxZK35Sinz0tw5QEWa+A/ucZsUlgxaM1M=; h=Date:Subject:From:To:References:In-Reply-To:From; b=EUuL74AVxIamP8ndGBQITYIeBbmxNy5HsNLrYWntO2EvsIQNELheXTjoCG0FfaFBq bLnOSTawNGRnmthhzYvH1CNuP+WteCMg8HdHxKr+xfMjXTZtKQayWbZzb3/F3TF+O4 8bdhRv/Cb4lOtCGl8D+LuNl5rHWQCOZLR5hw9TCPUoRUx49zTZcUFy9zV2SSGoRI79 WP60IGNYOkVEqKcxX40YqOeAHsO2RXVDTplbv6v6wmTLq44YFiSDhXHnPe6tmCtYmp KNwDRLoDrs6Q43hegDdz8s86lNdH55P6pM8VaymTlWU9dK9OchPr+nPVx3KSNY2guU tFSGH5z4Fa5Lg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 74F871805EA for ; Fri, 19 Apr 2024 21:30:01 +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,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 19 Apr 2024 21:30:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1713562161; bh=vTZ5L3WaZUOm8IqvFy+f2XJgRbrstukye/zIJMs/ZoI=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=A/js0ujizbGMnTolt6cSJRz3+cgRxi94Jwp1NP6f4Jk3R/8CW0wSG1xY2h7DrCO6p 6W1/L+O5BTuvIdACGsOWFkAGtbFjrx9tbcYwVPoBqeyTfvzkvHe6K7D0BHuoqihvzY CgT+8r8oP791JTDFzJ+HdlnnaIVyGGfFfPA+eO0VLWzVQxaNjinOpwAbksPPuAWOBF vpszm/tgnnmvAHh7SyklHXCb9bTRvR1khkm8CeuN0x9+OBMSL4RLq60duiKsdPaAgE aQT7Msmg5y7zLsTOLTs8NY1a0QuyTSr7fbmOJSZJvgDy/WWhML8DeNM36BGT0Wr10a Rc2HSfEuNvREw== Message-ID: <23f2275a-7a26-4f8a-b5c1-d92ed0298d1a@bastelstu.be> Date: Fri, 19 Apr 2024 23:29:21 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Subject: Re: [PHP-DEV] RFC [Discussion]: array_find To: =?UTF-8?Q?Joshua_R=C3=BCsweg?= , Larry Garfield , PHP internals References: <24e4529d-0b75-44de-90ef-34de5dfb1c99@wcflabs.de> <278889be-82ab-4827-a9e7-801b5ba2d8f8@app.fastmail.com> <45b726f4-8085-43e2-b701-6b35bc249409@wcflabs.de> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi On 4/9/24 21:49, Tim Düsterhus wrote: > However I'm not sure if adding new array functions piecemeal is the > right choice at this point. array_any and array_every are conceptually > very similar to array_find and are missing as well. In fact > array_any($cb, $array) = array_find($cb, $array, true) !== null and > array_every($cb, $array) = !array_any($negatedCb, $array), but it would > make sense to have them explicitly for clarity of the reader of the code. Thinking about this: I believe that it would make sense to bundle array_any and array_every (or array_all, see below) within the same RFC due to the similarity. It can be a separate vote for those two, but having the option of getting all three would probably alleviate my concerns of adding new array functions piecemeal. The implementation should be trivial, because it effectively just changes the return type. Nevertheless I'm happy to assist should any issues arise. As for the naming: JavaScript: every + some Haskell : all + any Rust : all + any C++ : all_of + any_of + none_of Java : allMatch + anyMatch (in java.util.stream.Stream) Swift : allSatisfy + contains(where: …) It appears the commonly used choice is all + any. Best regards Tim Düsterhus