Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:114903
Return-Path: <nikita.ppv@gmail.com>
Delivered-To: mailing list internals@lists.php.net
Received: (qmail 90089 invoked from network); 16 Jun 2021 08:49:26 -0000
Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5)
  by pb1.pair.com with SMTP; 16 Jun 2021 08:49:26 -0000
Received: from php-smtp4.php.net (localhost [127.0.0.1])
	by php-smtp4.php.net (Postfix) with ESMTP id F26CE1804C8
	for <internals@lists.php.net>; Wed, 16 Jun 2021 02:06: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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,
	DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,
	RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS
	autolearn=no autolearn_force=no version=3.4.2
X-Spam-Virus: No
X-Envelope-From: <nikita.ppv@gmail.com>
Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51])
	(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 <internals@lists.php.net>; Wed, 16 Jun 2021 02:06:05 -0700 (PDT)
Received: by mail-lf1-f51.google.com with SMTP id i13so3086727lfc.7
        for <internals@lists.php.net>; Wed, 16 Jun 2021 02:06:05 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=mime-version:references:in-reply-to:from:date:message-id:subject:to
         :cc;
        bh=SnUtyn/XXDdX+KuuVg7c4RH9Seqxa+yxUYbNVtmcvyM=;
        b=Z1aV3lXkddt53FjUu90qcYy8VCw6xDRIvfQDTnxx19rB1+1/6tJw9UKzPjrB3GZJ4K
         lfoUa0BPangiw1uRSyUVhXHhRhNxMcEPyR+2XpiWGV/kiFNCQhYmQrFMb7zrIqomsyoj
         R2ddag84MWzMZXleKtt+PEh2ad/43uE2DilUNYkjgq0WEMYsjRmeP7XW5FFnCI1pJrrv
         kTLFmgPTpmkatMnQ6/bmXn0IgjqA3mOd0xmm44Q8fmJXrcKib87kuBZO3QpdzjxV2y8D
         VnbSo/cx3PCV2cX4B9UGn3u5fZbsb9mSG9P9lVtm7dfXr1FGMZqVLo/nyPvtv/d+TdaP
         0jSQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:references:in-reply-to:from:date
         :message-id:subject:to:cc;
        bh=SnUtyn/XXDdX+KuuVg7c4RH9Seqxa+yxUYbNVtmcvyM=;
        b=Jvn38WjzUKy48cO8QjS0D22LGb9MxfTmTm77ZTlulK+unLkQLaR1XXiol/rTOVBrOU
         E+Y6Xeu/9lIhaIqhoSLuTQBRo/0lFYDBmimkwmIJX22wTyePmv3MaFFIfQMYj5hLLnK8
         aUAeofCRzkyCjtbsnO8jTSlFBrBfMFYaDyy54nnYZagueKi3qG2abTy6IpEdYTo4Rp6h
         QLcxKonir9pH9B+rvqjqr9IpfVFsq1pC6x/D8SBJuyLK9kR5cTdFzZzZ3U8bNmTFd6Xr
         d/Y/enKzGYoWKB1FHmek4YtueR/57ieJxDlalUPqJNwbGMNvPNkhp3QRJN3IyKsuIivB
         C85Q==
X-Gm-Message-State: AOAM533/Y2V5lu+5Yq/n352UtbXW8kRPkpYKH1UhgYCvqJH+POVtV8l2
	ZOoyVp6xQhv8zEnc8Lb/CTjyG2NHKYZuizwvqqc=
X-Google-Smtp-Source: ABdhPJz2SIfC3SDaqlgE3r2Ll7wMHRWSETfXjH5J0DDrhXZPc3GaRDw/Oa4e9+fgOsGoK3Qt6R4pFsdMlJMKb16Qe2Q=
X-Received: by 2002:ac2:5097:: with SMTP id f23mr2863651lfm.315.1623834359277;
 Wed, 16 Jun 2021 02:05:59 -0700 (PDT)
MIME-Version: 1.0
References: <DM6PR07MB6618B452F34999B861638D84F9309@DM6PR07MB6618.namprd07.prod.outlook.com>
In-Reply-To: <DM6PR07MB6618B452F34999B861638D84F9309@DM6PR07MB6618.namprd07.prod.outlook.com>
Date: Wed, 16 Jun 2021 11:05:43 +0200
Message-ID: <CAF+90c8aHrm+R9+A-6bx2QnzmQHvqbgJcKzfnFtz6abHD1GnMA@mail.gmail.com>
To: tyson andre <tysonandre775@hotmail.com>
Cc: "internals@lists.php.net" <internals@lists.php.net>
Content-Type: multipart/alternative; boundary="00000000000028abee05c4de66ed"
Subject: Re: [PHP-DEV] [VOTE] ImmutableIterable (immutable, rewindable, allows
 any key&repeating keys)
From: nikita.ppv@gmail.com (Nikita Popov)

--00000000000028abee05c4de66ed
Content-Type: text/plain; charset="UTF-8"

On Tue, Jun 15, 2021 at 4:01 PM tyson andre <tysonandre775@hotmail.com>
wrote:

> Hi internals,
>
> Voting has started on the ImmutableIterable RFC
> https://wiki.php.net/rfc/cachediterable
>
> Previous discussion can be found in https://externals.io/message/114834
>
> Recent changes:
> - The name was renamed to `ImmutableIterable` to indicate that it cannot
> be changed after being constructed.
>   It was brought up in previous discussions that the previous name of
> `CachedIterable` could easily be assumed to have functionality similar to
> on-demand iterators/iterables such as https://php.net/cachingiterator
>   (Additionally, immutability is rare among spl data structures)
> - `__set_state` was added
>

Hey Tyson,

I like the concept here. I think the naming choice is unfortunate, and
causing confusion for people.

What you're really proposing here is a data structure: A sequence of
key-value-pairs. That generally seems like a sensible thing to have, in
that we can implement it significantly more efficiently in core than you
could do it in userland, especially when it comes to memory usage.

The issue is that you're not really framing this as a data structure, but
as an iterable. I get that memoizing an iterable was the original
motivation here, but I think it causes confusion. If this were
KeyValueSequence::fromIterable($iterable), I think that the meaning and
behavior would be perfectly clear -- of course it would eagerly collect the
iterable, there is no other way it could reasonably work! I think Marco's
concerns wouldn't come up either -- it's perfectly reasonable for a data
structure to implement support for serialization and JSON encoding. Not so
much for an iterator.

Regards,
Nikita

--00000000000028abee05c4de66ed--