Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101733 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23472 invoked from network); 30 Jan 2018 18:13:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jan 2018 18:13:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 66.111.4.27 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 66.111.4.27 out3-smtp.messagingengine.com Received: from [66.111.4.27] ([66.111.4.27:40603] helo=out3-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 42/F2-24062-EC5B07A5 for ; Tue, 30 Jan 2018 13:13:35 -0500 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id A7736211B0 for ; Tue, 30 Jan 2018 13:13:32 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute7.internal (MEProxy); Tue, 30 Jan 2018 13:13:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=5TRiuSB7fc6bEZkdf0zzF7UHMhOBW uqexPE48K3xcPU=; b=iQjWwZ+TOKDkIWZGS+VKbBaMSAXAxbt0QJksOt49r0YRA /4g3yO+kK9lmrT+E7HEq2xJTZQLzzAu1G3G6VGo9I87DdHFMrlHeKIM4wQkfAEfY wim2sUoGtw8FAa3BjhUDM+8vorsEQ0rdb31AEAy7RlE5xZShcGX9OqgDxhKY06Ju 278KFzYiTrfU5w1bnPKwUElnXnAhHDNl3fW0wOlz6PKZkevwgnFEDyopgTfIKTIn YkEVI1eE2iysmdxHCwADDiMssG64IgLJlpk0qCyhxSlS6QjJfnRnQnZFFprbDfdE 29166w+fmibShMKSCxsLyM8mNr8nul5ZM0Ue/7Yew== X-ME-Sender: Received: from vulcan.localnet (216-80-30-152.s3222.c3-0.frg-cbr1.chi-frg.il.cable.rcncustomer.com [216.80.30.152]) by mail.messagingengine.com (Postfix) with ESMTPA id 057FC7E585 for ; Tue, 30 Jan 2018 13:13:32 -0500 (EST) To: internals@lists.php.net Date: Tue, 30 Jan 2018 12:13:26 -0600 Message-ID: <28100667.gh41XH5Xuc@vulcan> In-Reply-To: References: <4026445.Wp3pesFrPl@vulcan> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1879744.kmXkhGkcey"; micalg="pgp-sha256"; protocol="application/pgp-signature" Subject: Re: [PHP-DEV][RFC][DISCUSSION] Collection Inspection From: larry@garfieldtech.com (Larry Garfield) --nextPart1879744.kmXkhGkcey Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" On Monday, January 29, 2018 6:46:10 PM CST Michael Morris wrote: > On Mon, Jan 29, 2018 at 6:16 PM, Larry Garfield > > wrote: > > Really, these functions would be useful only on arrays, period. To allow > > them > > on anything else is just dangerous, and on other iterables there are > > better, > > more robust approaches (as discussed elsewhere in this thread). > > > > As you've demonstrated they're also quite compact and effective to do in > > user- > > space, so unless there's a massive performance difference of moving them > > to C > > they don't seem all that appropriate to add to the language directly. > > > > --Larry Garfield > > Didn't you personally raise the issue of hard dependencies doing this sort > of functionality creates? Implementable in userland or not, this is pretty > low level functionality. I don't recall doing so in this thread, but I most likely have on some other issue. It's the sort of comment that I would make. :-) However, that's for a very commonly used function where just inlining it is prohibitive. As you've demonstrated below, this functionality is easily a one liner, and it's a one-liner in an assert statement most likely. > Hmm.. If limited to arrays only then array_filter with count is pretty > close to what we want. > > assert(count(array_filter($a, is_string)) === count($a)); > > That's not optimal though - granted assert code doesn't *have* to be > optimal, but that's still a wordy construction. Personally I think that's fine, and doesn't need a language-level utility function to wrap it any further. (Yes, that's a subjective metric. So are most statements about what should[n't] be included in the language itself. Others are welcome to disagree, but this falls below my threshold of necessity.) --Larry Garfield --nextPart1879744.kmXkhGkcey Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iQEcBAABCAAGBQJacLXGAAoJEODDCsAxcWF3pYcIAKtypYE8+Fo084ja1m3Rh+nk mLyg8EriMImnfAgK6gpxlKq/JV/rCa285wn6UOKNMbCD/KfB1JkrtZGp87u+myN6 MeqngJ5/74d3xtHrZuSUJxo+FArbIPQO/Z0K1A1VO7ee7h7NCuuvhobr77p9jWuK bMrEfXINQY3bjs6aBo1f4d90Std2CqE08ren3fHHFrx2AXZ5TP0chTWz/MmE3vkH F9PwYitSHS4T4Fyq+h10vXnEB4VhJmK1NmHib6GPQMELeVQVgVRGJKcIzgchs+A6 W89yxu50KxiM/sD06l7LnJltloX1egEf4OXE/oVv6pH/aTZpXbcBwwNmo6Jr7mc= =SYY9 -----END PGP SIGNATURE----- --nextPart1879744.kmXkhGkcey--