Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118006 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 97644 invoked from network); 20 Jun 2022 10:19:00 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 Jun 2022 10:19:00 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 812F8180210 for ; Mon, 20 Jun 2022 05:08:00 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 20 Jun 2022 05:08:00 -0700 (PDT) Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-317803b61e5so72629107b3.1 for ; Mon, 20 Jun 2022 05:08:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=VimJivYvgsXxiAcKJO85xGKS38Ty3Q5NNM0tu7FopQ4=; b=CyDiwv5aEzIG5sx1S7FzWn9gCBTIBEwz+AIQXnea441i2l41JSWWPQkaQ4ZHIg//DW guGnu64L6uWehEs8+Ry/x8djiLbKAO7weSj7zCDBz/OgaES5atN11wd8bdDklO2i1Knd atVzkMEsizibC+OLgIZz6n3fRWrsAsEIk8oDYrvYncBZDQe+6T3oFIUsGDeRAh1MJNS0 vE7RcOYw8xJ2RoD59SabkXDUi2FbEJwFQ4JHTFkDRzFID92+gszVvCbZWBXuKIjbQoPj ZBd1g1ardRyEKp16O11KpgfyGks8JHVxlJonEtjalfQ/SziwvKDXzECmA2VchIjJ5jHi zO9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=VimJivYvgsXxiAcKJO85xGKS38Ty3Q5NNM0tu7FopQ4=; b=DIh14tNSeUBGgX6MSjtY6uLjJAV0acJwDZgLAQ7LS7VTu/9aHGh56J4OXwIj8LL26e 93Y1JsF4xP9XZyQhOWhigDAVO2wvqhnhqxHTEyIrBBP7qvtK7hekYRCCEOIlQoAofFuT nZb/1bpo9sNPacAjiTRFb5GrfbeEagcKw7ztx20uvtcgsuN+bygkiPMWqqyT4CjCVlcC 8Z6o+ee81Iw0B8xaYGvbl0/jwbvd/zHZ5qDg7jr9JFKvebdejGjNFdd8qmIG/PtUKWym WJbSTIAMuNPNilg1oZ647mc4rDhnq0O6VuWJeZZFxOvfCuTDHnHBWXQzEJTg+XWSmZOn MSLg== X-Gm-Message-State: AJIora+9olsuLJmBiRugfrc7ba0mc2Ix0CpBM66oxpX1wtGK6iIU+C8p /bzam7dea+4Y1Vq73I4gXOl6p/KwbmZDT5eeUz8Up7gBMw== X-Google-Smtp-Source: AGRyM1sTh6nVkAxFwDT+TYlvjm5armhbdShwZBk0/oKB9ewJOI91hSM6k76+XBt4u6yGVQ0MFpNpwPTgCmcZ3FbZp/A= X-Received: by 2002:a81:12d3:0:b0:317:aa20:e4eb with SMTP id 202-20020a8112d3000000b00317aa20e4ebmr10376103yws.352.1655726879444; Mon, 20 Jun 2022 05:07:59 -0700 (PDT) MIME-Version: 1.0 References: <4af09139-7db0-e701-69e0-de527afcfc6c@bastelstu.be> In-Reply-To: <4af09139-7db0-e701-69e0-de527afcfc6c@bastelstu.be> Date: Mon, 20 Jun 2022 14:07:48 +0200 Message-ID: To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Make iterator_to_array() accept all iterables From: guilliam.xavier@gmail.com (Guilliam Xavier) On Fri, Jun 17, 2022 at 7:21 PM Tim D=C3=BCsterhus wrote= : > > Hi > > On 6/17/22 18:06, Guilliam Xavier wrote: > >> https://github.com/php/php-src/pull/8819 > > > > Just so that it can't be said that it hasn't been asked: what about > > iterator_count(), and iterator_apply()? > > I also came across those, while implementing the PR, but I intentionally > did not touch them to keep the scope simple and because I think they are > less likely to be used generally. Okay :) > - `iterator_apply()` is easily replaced by a foreach loop, because the > return value is pretty useless, so it is not likely that a nested > function call is going to be used. Well the same could be said about `array_walk()`... but anyway :p > - For `iterator_count()` one could to `count(iterator_to_array($foo))` > if my proposal is merged. This come with a bit of overhead, but at least > it's not as clunky as `is_array($foo) ? $foo : iterator_to_array($foo)` or as `is_array($foo) ? count($foo) : iterator_count($foo)`, for that matte= r ;) > If a RFC is desired, then I'd likely include all three of them with a > vote for each, but I hope my proposal is simple enough to not require an > RFC. Well I won't be the one asking for an RFC ^^ (and you're right that the `array_*` functions are far more numerous and [at least in my experience] used than the `iterator_*` ones) --=20 Guilliam Xavier