Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123427 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 3B6891A009C for ; Fri, 24 May 2024 23:19:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1716592823; bh=AcnxK4i1DSi7faI66Kx6MLFo26EGPeDTgStV9xiiM2k=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=gIfMOong8BPgqu/ds6kagjmLv1vjjM3RUXiDWcS9qZX9MfmBIbKhgdEghqCjQm/Sq 0eu/fTP7GJtIgHj8jgVCQU77fib84Gib1e7u5KNc3o2btXUUqc7klcNWMkA6LTP9N8 wnS2n+jOGzd1XOc4WJhst9wd1NzO+7zErRGhrYz1uNZvY4POKE4OxnKCdHwS0Xg9U+ 0yPU2HXuC5wR+720wXvROIvZXTqFEjn47s2IuvWSg3x7e+Ss7MmE/0gIQCLVXnK1wV Bo/Et3KzUhOsq32lUYZ95yEWsXLtJAT+9sYr27jejmzo0H6nYuS/AyDmiSIODa/U0/ EiWcLiHfwjOpA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A26DB18006E for ; Fri, 24 May 2024 23:20: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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 ; Fri, 24 May 2024 23:20:19 +0000 (UTC) Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4202ca70287so23210795e9.3 for ; Fri, 24 May 2024 16:19:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716592760; x=1717197560; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Jurp0ZNT6D8OqceHJsFZW5ZVPZjLCEFeQcvNZDkrCrA=; b=gSBT1Ameh6LMaBsZ9sPLPpyV/u4S5ws9iLwZQdMPPoJpDC/AL5j8qxPf2XhSU7qjEc QMAU10pLDuXXsFy/evVAXO+bzpQBZQWjHp2xtaZ2vPgsoJsCo44pCcTXIpeVCU/iX9ef Q3EM7BLCtKznjw7WRoiWd3jeaEQI09EiHTpiiK2XBG/5kxy0pkmKmcwj9mCKsf1JRgiT /XhIk5XFDAjmNcB1NxdTq8O04igo8DLUIab3M2eHLZ55R6/ABeyLTpN8PuEcNx71GYN6 UtTz/mbQlMYak1AcaC5hBHbtecRSLFaPvVNYaOkd0UCm3bJtBUvMG8+v8ELq701HTUyc zh7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716592760; x=1717197560; h=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=Jurp0ZNT6D8OqceHJsFZW5ZVPZjLCEFeQcvNZDkrCrA=; b=iPwQyjFYOpm+oKj1aMzEbo5p7DmS2+RyEqx48zjpxazmRHOueRfSc3snf2FgV7Gu4G xqycLpc0QQkd1NErnOglvln7DDoee1ie+RRDVk+qJ7eHIyXBtugtrlc0jeMhsPO7sq0D Olfb9tcbFrt9ypYASbTPaH0WeAYgexMZyVPiBVYaepNyYk9POmk4NSbAEUcs1IyP4k1q E0rIBgAHD4BDlW370gmYt+RtnGuYh/miblIt9znN3Ur4sA/nS+sUK6QZci1dALe9elCd 4iqzRX7S1Y1kEjqaTmonMRomlR28/MJe0YWDU/WUFNh8tXBwg92s7OIXYCMtE+FlmXs2 odjw== X-Gm-Message-State: AOJu0YyU3AhiBFh1rn0kqt4v/jkT9f9cPp1fGDPJT8Qkdh7jhLuQkfoI u3M6wnFTsEaATGFObZUkfF4N+b3MeaaIb/B0K/YdZZGfBaE1hijoeOn7A6LGNsVnmP2qDhvOtb3 tld7FtpYcfv43DRqORpMSxIWSSJTigQE= X-Google-Smtp-Source: AGHT+IG24U7vGkJCXPvvXS+C48iCPJG6fiesaHqVai3VFZrB95XcNxRJUnNkT2VtJ8X5bPcp7IOy36O9PZyNICyo0kI= X-Received: by 2002:a05:600c:5128:b0:41c:2992:a3be with SMTP id 5b1f17b1804b1-42108a0d3cemr33413935e9.29.1716592760081; Fri, 24 May 2024 16:19:20 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <24e4529d-0b75-44de-90ef-34de5dfb1c99@wcflabs.de> In-Reply-To: <24e4529d-0b75-44de-90ef-34de5dfb1c99@wcflabs.de> Date: Sat, 25 May 2024 02:19:08 +0300 Message-ID: Subject: Re: [PHP-DEV] RFC [Discussion]: array_find To: =?UTF-8?Q?Joshua_R=C3=BCsweg?= Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000b0537706193b6562" From: udaltsov.valentin@gmail.com (Valentin Udaltsov) --000000000000b0537706193b6562 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Apr 7, 2024, at 10:20 AM, Joshua R=C3=BCsweg wrote: > Hi > I have created an RFC to add the function array_find which returns the > first element for which a predicate callback returns true. This is a > function which I missed often. Furthermore this type of function is > implemented with other programming languages like C++, JavaScript and Rus= t, > too. > You can find the RFC at: > https://wiki.php.net/rfc/array_find > Proof of concept implementation is in: > > https://github.com/joshuaruesweg/php-src/commit/9f3fc252b92f534d498e5f1e6= a463e15f45da208 > I'm looking forward to your feedback. > Cheers > Joshua R=C3=BCsweg > > Hi, Joshua! Have you considered renaming `$callback` parameter to `$predicate`? I always considered "callback" to be a very generic word. Predicate, on the contrary, implies accepting a value and returning a bool. --=20 Valentin Udaltsov --000000000000b0537706193b6562 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sun, Apr 7, 2024, at 10:20 AM, Joshua R=C3= =BCsweg wrote:
<= u> =20 =20 =20
Hi
I have created an RFC to add th= e function array_find which returns the first element for which a predicate= callback returns true. This is a function which I missed often. Furthermor= e this type of function is implemented with other programming languages lik= e C++, JavaScript and Rust, too.
You can find the RFC at:
Proof of concept implementation= is in:
I'm looking forward to your= feedback.
Cheers
Joshua R=C3=BCsweg


Hi, Joshua!

Have you considered renaming `$ca= llback` parameter to `$predicate`? I always considered "callback"= to be a very generic word. Predicate, on the contrary, implies accepting a= value and returning a bool.

--
Valentin Udaltsov
--000000000000b0537706193b6562--