Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113119 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 19763 invoked from network); 8 Feb 2021 22:46:08 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Feb 2021 22:46:08 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 571291804DD for ; Mon, 8 Feb 2021 14:30:58 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 8 Feb 2021 14:30:57 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 3307A5C01D3 for ; Mon, 8 Feb 2021 17:30:56 -0500 (EST) Received: from imap8 ([10.202.2.58]) by compute4.internal (MEProxy); Mon, 08 Feb 2021 17:30:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=tFeQmS8mgxR6qv84sSW0eUbQN+dfe1wkDvc+jkEHn 00=; b=uWuS0ji5RNnyOyShzhNil9AXOUshjFPctGXlsmZ2k9PIp8cdQtBp2/HT5 eN4SEgXX67QENlYt6J5RF5JP6Z0b90liu6XrikWcXZFDAGi8SnRn7oxAWCQo5+VX lnbesLbjDuiA6FUwbtQyYO5T6/4JA5L3Y6s910y9jFdc8MFgX1BBuG9eA4pBIpTe I1NCd1nqVY1sWtiKfTW2644iChJrAYmwmzDIHZx9UL47uwwJ+D8gskoFZvy3vOqp nugRAXyUUBlnBLvxgI5Wk1dVONJqsYGw0jGhsHrB7KCvfGo3QE5wknqjvofK+mFA ivYz9SXlK9A6SaMZaLK+Qh4/U7Wvg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrheefgdduiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepgeeghefgteejheeggfeghfelueeggfdtjeeivedv tefhveeguedufeelhedvteeinecuffhomhgrihhnpehphhhprdhnvghtnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhf ihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id DD1613A0074; Mon, 8 Feb 2021 17:30:55 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-93-gef6c4048e6-fm-20210128.002-gef6c4048 Mime-Version: 1.0 Message-ID: In-Reply-To: References: <77dfe9e5-a6d1-4a41-bceb-454a65cf34d0@www.fastmail.com> Date: Mon, 08 Feb 2021 16:30:35 -0600 To: "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [VOTE] PHP\iterable\any() and all() on iterables From: larry@garfieldtech.com ("Larry Garfield") On Mon, Feb 8, 2021, at 12:02 PM, tyson andre wrote: > Hi Larry Garfield, >=20 > > > Hi internals, > > >=20 > > > Voting has started on https://wiki.php.net/rfc/any_all_on_iterable= and=20 > > > ends on 2021-02-22. > > >=20 > > > This RFC proposes to add the functions `PHP\iterable\any(iterable=20= > > > $input, ?callable $callback =3D null): bool` and `PHP\iterable\all= (...)` > > > to PHP's standard library's function set, using the namespace pref= erred=20 > > > in the previous straw poll. > > >=20 > > > There is a primary vote on whether to add the functions, and a=20 > > > secondary vote on the name to use within the `PHP\iterable` namesp= ace. > > >=20 > > > Thanks, > > > - Tyson > > > -- > > > PHP Internals - PHP Runtime Development Mailing List > > > To unsubscribe, visit: https://www.php.net/unsub.php > >=20 > >=20 > > Ak!=C2=A0 I literally just finished reading it and wanted to note a = lack of clarity on one point. :-) > >=20 > > The signature of the callback is never specified explicitly.=C2=A0 T= he ternary is a bit confusing.=C2=A0 I assume the signature is=20 > >=20 > > callable(mixed): bool > >=20 > > But that's not made explicit.=C2=A0 It's also not made explict that = omitting the callable collapses to "is truthy".=C2=A0 That's a sensible = thing to do, but it's not stated explicitly anywhere, just inferred from= the code sample. > >=20 > > I'm not sure if it's safe to clarify at this point as the vote just = started. >=20 > If there is a callable, it allows `callable(mixed): mixed`, > and converts the callable's return value to a boolean. > So omitting the callable is the same as passing in the callable `fn($x= )=20 > =3D> $x`, which is equivalent to `fn($x) =3D> (bool)$x`. > This is exactly what the reference implementation would do. >=20 > I definitely should have clarified it instead of assuming that the=20 > reference implementation was clear enough. >=20 > I clarified this and gave examples because the RFC started a few hours= =20 > ago and the implementation didn't change. Oof. I'm glad I asked, because I don't like that at all. If available,= the callable should be returning bool, not "anything that may be truthy= /falsy." If you have an explicit function, it should have an explicit r= eturn type. A truthy check is a reasonable default, but not for when yo= u're opting in to specifying the logic. I am in favor of the RFC, but I will have to consider if that changes my= vote to No. --Larry Garfield