Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123016 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 DA05A1A009C for ; Sun, 7 Apr 2024 14:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712500573; bh=SYbN3HEmiwiCGOnyhYeGybmkSfcQQWy1GBoGBaGP3ro=; h=In-Reply-To:References:Date:From:To:Subject:From; b=I5j290nKL/DKP9f0uFDcNNf0MQR6tGZC800zPYBHrEHpC7CX4q8ltnscsP2Lu0S8P TlITAXbNzfxleC8BVVFwj6P4P8tlyc/qKBjODLZ7KRqBy8xisRXC99nk0fCpfXwohO gDnSI4zx5qP+A4L1GOFDaJY7H559mJT6tlpPNC3+H5GZqUkiETLGy+7OUZTYW1Foe4 XOLEyl9oOIBLvTQZgziZjo9Nk40lQfPzWYQ/I5aD8lDfL2Ff3wDkYKITkFnOrDmCRp qhVAmMpQURnaAYfO9R33LpXUahXhXvZrhJyb6RFm6k1Fnnn/K6+svypaB1AU9UHUiS bZqINPz5XcxNw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 52722180891 for ; Sun, 7 Apr 2024 14:36:12 +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,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (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 ; Sun, 7 Apr 2024 14:36:11 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id A5E643200A0F for ; Sun, 7 Apr 2024 10:35:39 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Sun, 07 Apr 2024 10:35:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding: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=fm2; t=1712500539; x=1712586939; bh=g1PpYWElrcqWe8P1iF/7n o40dx+MaqK7yEEeShR6iYA=; b=WJHyPnmC3XTaXrlZQCsJWC1LsyyK3jP+f5fy4 MZ5ve7l7I/J3O7nTwsEl9GC205M/eQsFEu2DLn5BBIiYA/csS7lC7D24q86WazBG R5h3PBhfIp9Q0ouEUKZiiroC116J6PLT5S258opMTIt91Vw6gxYyaQRIJOcdfdsd lI291tDqADpwbb1r9Vx+Oh8zoe+dP355sG7fgTVZMeD4PxAHQyilnRO2sAFoGsGB jEIJ4OiFZ+Rg7ZYL2mo3AcnBPqN5AQFyF56GlCGfxklyFYB0QS43DMMaEnuZMsxR /IbQwQC4rpHClsYj2r/9QD+KbxRbjwkdSCNq3lH2N4ZXbjTyw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1712500539; x= 1712586939; bh=g1PpYWElrcqWe8P1iF/7no40dx+MaqK7yEEeShR6iYA=; b=s NCDrOIPWx+KGLTiA5hhWDNQ29BG2xW29IDHH9uh7PPSLQogXS6N5a3IJTjvlktRp f1loKxLYQXfuC0JZNSh82kpX70wcDEvS4/NKruMYiqtj9TNYFcuHC02Elqc10nyJ JS9pToOyaRKw468mwkqjo16BwX2um0nUt1sBSxU7FfIjM63j2fwGVXGQNGFTBo3D m9zpIOtb9LopNxsQvo70saWGzlOZgJycWWzU13yFc9Pocc5uzhEaAPnt4v5qRVP7 GWgMEZjCRsnHpsEuGoHsUMBwtWefSybMb8yX37Cjv6PFq9hmCW9qoTb5pcyK/cq2 CQUg5XTGwiX1HP0hU20uQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudeggedgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepheetvdehffekieeiffffueevhfeugfegfeelgfef feeutdejheeileefvdekveelnecuffhomhgrihhnpehphhhprdhnvghtpdhgihhthhhusg drtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhm pehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id B84061700093; Sun, 7 Apr 2024 10:35:38 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-333-gbfea15422e-fm-20240327.001-gbfea1542 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <278889be-82ab-4827-a9e7-801b5ba2d8f8@app.fastmail.com> In-Reply-To: <24e4529d-0b75-44de-90ef-34de5dfb1c99@wcflabs.de> References: <24e4529d-0b75-44de-90ef-34de5dfb1c99@wcflabs.de> Date: Sun, 07 Apr 2024 10:35:18 -0400 To: "php internals" Subject: Re: [PHP-DEV] RFC [Discussion]: array_find Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Sun, Apr 7, 2024, at 10:20 AM, Joshua R=C3=BCsweg wrote: > Hi=20 > I have created an RFC to add the function array_find which returns the=20 > first element for which a predicate callback returns true. This is a=20 > function which I missed often. Furthermore this type of function is=20 > implemented with other programming languages like C++, JavaScript and=20 > Rust, too.=20 > You can find the RFC at:=20 > https://wiki.php.net/rfc/array_find > Proof of concept implementation is in: > https://github.com/joshuaruesweg/php-src/commit/9f3fc252b92f534d498e5f= 1e6a463e15f45da208 > I'm looking forward to your feedback. > Cheers > Joshua R=C3=BCsweg I'm open to this, but two points that I'm sure someone will bring up: 1. Should this work on arrays or iterables? This is a long standing lim= itation of PHP. The array operations don't work on iterables, even thou= gh we've had iterables for 20 years.) 2. Key handling. It's good that you have looked into this, because I wa= s going to mention it. :-) However, I don't think a boolean is the righ= t answer, since the question is binary, not true/false. (Those are not = the same thing.) I think a small return-mode Enum would make more sense= here. --Larry Garfield