Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111757 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 50002 invoked from network); 1 Sep 2020 00:58:35 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Sep 2020 00:58:35 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E9AC91804C2 for ; Mon, 31 Aug 2020 17:03:05 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10olkn2098.outbound.protection.outlook.com [40.92.40.98]) (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 ; Mon, 31 Aug 2020 17:03:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=msNtBsDHQ1M8DjB6VPBWPOqj5UcaFKngX2Di9uQrQzK3FDuvZeXPYJV++cWG/U8MvZftmxx4nLvnCk9A6ALgH0xxLE/FnNCvxcf6KRftZ5LLubwHxtEZomKq29qi6oMf+mkZBfStDSS4y6afdwJIgfBmTIGOZe6M4JwpxtRoPd4vf3ioeAbtn+KB59fM1tENl2KTmS746fpkyE9hIlLMTqY0cY9q1PEMAIX1YgN0Wcc45OV2fH4Jnzs2bQSKAA3bC5ifKYFSIdTuBL9ROrV++Z5yN+mXb3LU++QWk4H95FftkGaUpt9pS1csI0KBtH5gMv2/xjnYJ8k0rUnc9I3p6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=25RYpifJr6zZovv9CtjqQqNj3FWj2MK9YSDV6rNMYrU=; b=SmpPTNJFIRA0nHRGGSExOZFj9Tnjf3LgYnf0cunqQc/JCyBX1Dw6tqQdQJNIsB/idO92ITlLYShffw1KCZlzVVWLlk+7lyQqACswExaOzRdqcn9R4xxwpYVn0Mer0Sc+xWhZpsElJwIyn083s36wsTByWO0fk9F3vC/YduE20ogeqdhT4xhC26QOzlHPRpfFnfVGNLZubcQ0e/4+s5SshjFL/HTBoeYZhz+TXEuFAvKnnhfvZZ5mSlj0NEBQIplNE4Gw8xSDJ55PjgJO1PKViQkpVQe2BoUZzIG8a6EvtTHr7FD4841PfKE89LmtLqUErH/gPrty/PFbS9zfR1wCBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=25RYpifJr6zZovv9CtjqQqNj3FWj2MK9YSDV6rNMYrU=; b=SMv43qek/bsK2RoTOZCV569n3Y8MdokNHR8Ce26kzrIpQiFTY8ArRy255/lGaSE1+195ySfFqheshOTj6sWJyz9nF78kjCHr6oLam3bKdzqt03UPQhtJuU1I95uQqXN+paEdxJOhL7YuWPtViuirb15rmxAYt9tgcmconwfguhIYnPj0w4/Mwu4exqLjb8aNrW62Sm+pYnPlX9TT0Ln3HUXtH8fx06wrdoBThgefljBCMB6PzJ1rDg6obx6Dt/3gWpqdrWgSs7ZZrgIPBwzySr/k4eepPAkclWU5Q6cUyJyZozsf7tXIUtlJslbBHw0ht2cQhO74Cied57f/E6Cptw== Received: from MW2NAM10FT046.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e87::51) by MW2NAM10HT089.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e87::420) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.23; Tue, 1 Sep 2020 00:03:04 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e87::50) by MW2NAM10FT046.mail.protection.outlook.com (2a01:111:e400:7e87::205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.23 via Frontend Transport; Tue, 1 Sep 2020 00:03:04 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::f9d1:ed5b:8625:bfb4]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::f9d1:ed5b:8625:bfb4%7]) with mapi id 15.20.3326.025; Tue, 1 Sep 2020 00:03:04 +0000 To: Levi Morrison CC: PHP internals Thread-Topic: [PHP-DEV] Proposal: Adding functions any(iterable $input, ?callable $cb = null, int $use_flags=0) and all(...) Thread-Index: AQHWfj2/bRooGr39CkeRSgZBGY4s+alReqSAgAFtmpc= Date: Tue, 1 Sep 2020 00:03:04 +0000 Message-ID: References: , In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:99986D075FB2E38BAEA605074786B1F4479B8D1C986EA6875523EF322A0037D6;UpperCasedChecksum:97B1F97FA4C7583C970F094BA87FD8C7A5EDE7B353951C5C3DDC326360D3439F;SizeAsReceived:7298;Count:45 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [AgdXadLroV6bqfQY7Vz20NQNSyb5yShSH8Of81j2snM16j9Cba24ezeJmOq5XKgm] x-ms-publictraffictype: Email x-incomingheadercount: 45 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 89641c8c-1058-4c2e-9dca-08d84e0a6635 x-ms-traffictypediagnostic: MW2NAM10HT089: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: MVehCaD3fZR3jhdutVodIlQOiv0Q7EWmTzcz/OKxduSKw+MvQy5aEuACL/X+De9yN9QORwsy4lRYB68+dJjMAVlsotdUd+sUhCUvBRw+NJCbnVVRw7f4eMnlo5T2yx9B0sUj+3l9kskFQUJ0ZJehtu551wdN88ou+YTZR0H70nEzUL5Pdl0yUEWEpecst7RauH/5k2nLZ/NMUK0By2loOcoHTPAu57yUbUWQ1vkKNasT9BDoByiyDSUkLnKfTqJZ x-ms-exchange-antispam-messagedata: gsraMIvQuEKktb5qq4sKsdg+91PtEd9ugL3t+WUgPh4LcLR3XCH2UJpWtJmLTLDmeRCukAgXEyELoPD1jpETm0mvMG8RP/8eQqlx5JUldp9rQCMnVWvRvRY9GJbAa5/g7itVnGuzs1FMd05Ogrfe4sm5hCVQ+gq5fJ5jZv0hHo7ifSfFc/aJdqx9bo3qOP95XtYdA5trz/HFIPOxYW1PXg== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: MW2NAM10FT046.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 89641c8c-1058-4c2e-9dca-08d84e0a6635 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Sep 2020 00:03:04.3894 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2NAM10HT089 Subject: Re: [PHP-DEV] Proposal: Adding functions any(iterable $input, ?callable $cb = null, int $use_flags=0) and all(...) From: tysonandre775@hotmail.com (tyson andre) Hi Levi Morrison,=0A= =0A= > I was actually working on this sort of thing recently. _Technically_,=0A= > you can support `all`, `any`, and `first` by using a single function:=0A= > =0A= > =A0=A0=A0 function find_first(iterable $of, callable($value, $key): bool= =0A= $thatSatistifes): Iterator=0A= > =0A= > It converts the $iterable into an Iterator, then calls the callback=0A= > for each key/value pair until one returns true, and then always=0A= > returns the iterator at the current position.=0A= >=0A= >=A0I'm not sure that in practice it would be that friendly, but it's=0A= > worth pointing out for discussion at least.=0A= =0A= I'd find the `find($iterable, $callable, $default =3D null): mixed` to be m= ore user-friendly,=0A= personally, and would worry about accidentally increasing memory usage if I= left one of those iterables around as a saved value or a long-lived local = variable.=0A= =0A= There's plenty of time until the php 8.1 feature freeze, so I don't feel li= ke increasing the scope of this RFC=0A= (https://wiki.php.net/rfc/any_all_on_iterable)=0A= even though I would find some version of `find()` with a callback useful.= =0A= =0A= Thanks,=0A= - Tyson=