Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109789 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 88834 invoked from network); 22 Apr 2020 20:29:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Apr 2020 20:29:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 99A881804B7 for ; Wed, 22 Apr 2020 12:01:09 -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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS11403 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (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 ; Wed, 22 Apr 2020 12:01:08 -0700 (PDT) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 5B9025C0294 for ; Wed, 22 Apr 2020 15:01:08 -0400 (EDT) Received: from imap7 ([10.202.2.57]) by compute7.internal (MEProxy); Wed, 22 Apr 2020 15:01:08 -0400 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=3Te0VZkzg6bt32f01OYZDc25yJwRF1S850rSt3RUb 3o=; b=Fc+4V+FagrghE/KnhfVjBgKLRB4/gTKsU1t0oBZBS6/AQfQlSWEXAo05H BbtCBoknl1gMOBhDNpsDE+MT7mwyNetioEHhbVMlvDl4SDabK5HB5b3eQRtVbM8e jcZzgS9CCXXT4qihZucWf4XdgIs5pS8R8uRYTJ3LzlrW+G3j4mEa9qCnfJ1Bay7y T9fgu1M3L0ZTn9nhGlE65GvDu401iVHwWp9lqNW7a12xB2TjNVfEvCw/g1UoIbdQ 957OhyqTw3l+RLXOaKdX/oCUi2nwygnq4q1Z4VidBi+/q884/jfImqc8N6PIkhKV 9M0jFEqkuibFmJ2qZMbPVCsQS5p4A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrgeejgdduvdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhep lhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id D6015180091; Wed, 22 Apr 2020 15:01:07 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.0-dev0-351-g9981f4f-fmstable-20200421v1 Mime-Version: 1.0 Message-ID: <31441489-11c6-4d99-9c53-6ac0e877f268@www.fastmail.com> In-Reply-To: References: <4c1cd016-1e41-4ebc-afc4-d8d3cd1c319b@www.fastmail.com> Date: Wed, 22 Apr 2020 14:00:46 -0500 To: "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Any interest in a list type? From: larry@garfieldtech.com ("Larry Garfield") On Wed, Apr 22, 2020, at 1:49 PM, Matthew Brown wrote: > > Is it an effective subtype of array? >=20 > I was thinking it should be (with the auto-conversion mentioned above)= , but > I can see a compelling case to not have the auto-conversion when > manipulating =E2=80=93 while it would bloat the stdlib a little (we'd = need a whole > bunch of list_* functions) the separation would simplify things a lot = (e.g. > list_filter would return a list with sequential keys, whereas array_fi= lter > returns an array with possibly non-sequential keys) >=20 > And then you could cast between the two like "(list) $some_array" (whi= ch > would preserve order but remove keys) and "(array) $some_list" as > necessary. There could even be some automatic list <-> array casting w= hen > calling functions not in strict_types mode. >=20 > > Should they pass like arrays or like objects >=20 > Definitely like arrays =E2=80=93 I want them to be a drop-in-replaceme= nt for people > who currently use arrays in places lists are more appropriate. >=20 > > Should they be mutable or immutable >=20 > Definitely mutable, like arrays are That has a long list of possible issues with it relating to spooky actio= n at a distance, depending on the passing semantics. In some languages = lists are immutable, and with PHP's copy-on-write it may make more sense= to just go immutable. > > Are they iterable >=20 > Yes, the keys are sequential integers >=20 > > Does it make sense to add them without type enforcement via generics= >=20 > Absolutely =E2=80=93 this shouldn't be tied to generics landing (which= I'd imagine > is a PHP 9 feature at this point, whereas this could be a PHP 8.x feat= ure). >=20 > > can they be mapped/filtered/reduced >=20 > Absolutely =E2=80=93 I think we'd have list_map, list_filter, list_red= uce functions > to provide that functionality. Why duplicate all of them? Rather, map/filter/reduce need to be recast = to work on any iterable, which would then include lists. Or, if lists a= re an object they would be methods on the object. Hence my point. Lists would only make sense if we're also rethinking ho= w collections work generally, for which we're already overdue. Just tos= sing them in as yet-another-different-thing would make the situation wor= se, not better. --Larry Garfield