Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124120 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 7458A1A009C for ; Mon, 1 Jul 2024 01:00:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719795702; bh=Cqlp76e6wUWysVrBlePlWfNKuoOXt8Pdr/ume9fnAmI=; h=In-Reply-To:References:Date:From:To:Subject:From; b=eyDhL0D9outUwIqa/PL43si79JhJp98oio7KQfv7+6AhmRzT+SaF00MDkR6W0uZ0Q e5EYa+nHJWK6NT6VUpz18pqQWcj04bqK6uLejnYzC6uYcuzFPhxppSvNt6WFOOYLMW 13ouanbbzVHmmxdvT69PUu4pihBmBFmb/vRSVG/FY2foOEgNqbgtv96HhFDoCydtT0 UDqnQFUeZeSIHkn5g/+zzgqSDEu0+NdaY2DUta1utGR5sCVqKYmZcloTt1jwmIoiuN 1NxJiaee7w751HEbp4chURUdFMsUehtABLzNMHrpPqrQOMPqq1t536uYmEnZoRH048 irkjOCI7X6QRA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8251618003F for ; Mon, 1 Jul 2024 01:01:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from wfout8-smtp.messagingengine.com (wfout8-smtp.messagingengine.com [64.147.123.151]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 1 Jul 2024 01:01:40 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.west.internal (Postfix) with ESMTP id 962691C0007B for ; Sun, 30 Jun 2024 21:00:19 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Sun, 30 Jun 2024 21:00:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm2; t=1719795619; x=1719882019; bh=+RN2w7Volt9DkSGH4SVaw 7QPfB0GmMyphrwlMRWPjBQ=; b=r3uZvn/W4mmlih6FwVZPkOixyF3GFsY2aKwvA gGkzbV9EcoaLCVllDwDmrYHfHVJSlgoaIJ22nkOx9ac8k9yiL9eA15IDOmeEJuSo D2hQBajFjBdBk4OW0ePRUf8pLMh9M0dlHTVY2Ur0QGYXCtS/rWsdwzHPTyB+SrIx gLTessf13E6UfFqogStukIFXI5j++cn8pj6uhX2MInGanI1WFz2I4Z6t6rTubuhu Ab15/BbU8ySYKUZX1B0WLGMuAZ6Jj8dunnF64y4krmQhfYS8t32X+kaQ3Kb6nzlX a+VBosUeONcee/2gzuq9u2l3vbM5ng5VhfnI2bS7v9Faxt03w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1719795619; x= 1719882019; bh=+RN2w7Volt9DkSGH4SVaw7QPfB0GmMyphrwlMRWPjBQ=; b=b Te0YXMoz8POnWyVHPS9CZrxvKgNqydAH8zjN1mTM3yp60CDhjz55Zy01FxBjg5L7 +4PkGfVd/M75rD2jPbQX3hGcO2t2kNXGK121f/sojAMAxR0iO848a+yy59p9bMpd 7rdFjVS8n1b6jAerZgHqbgY6lzMMk+vHViBYB1sY49PMWaqg3HN8IiI6w7Pc6BzX z6K4+ABrfq/rrX1X7gAQolHV7+PrqY9wKg8bsOCQfgRDLdEhKCeu9Fcj5f0eT3aJ g+WgcjLEuwo9zWw9s6O0Vh06FFWvqr3f8/Vo+B5tgqKcSbQTaYfmj7gV2RtHFdY/ FD0teyZrMt4FR5/+k1uJQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddvgdeflecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtgfesthhqredtreerjeenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeevhfegvdegudefhfelfeeuleevtddvieevhffgveeh teeivdfhudffgfeitdeikeenucffohhmrghinhepghhithhhuhgsrdgtohhmpdhphhhprd hnvghtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhep lhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id C763F1700093; Sun, 30 Jun 2024 21:00:18 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-538-g1508afaa2-fm-20240616.001-g1508afaa Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <4996ae09-e5eb-4a8b-90e2-7461805c4cb7@app.fastmail.com> In-Reply-To: References: <4ECBB519-B129-426F-93AE-33738A1ABA06@miles.systems> Date: Sun, 30 Jun 2024 19:59:53 -0500 To: "php internals" Subject: Re: [PHP-DEV] [Initial Feedback] Typed Arrays Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Sun, Jun 30, 2024, at 11:13 AM, Micha=C5=82 Marcin Brzuchalski wrote: > Hi Richard, > > czw., 27 cze 2024, 22:33 u=C5=BCytkownik Richard Miles=20 > napisa=C5=82: >>=20 >> > I worked with Joe Watkins to do a proof-of-concept for generic trai= ts. >> > It's a bit old since it's from 2017, but could be a useful starting >> > point if you are serious about pursuing this idea: >> >=20 >> > https://github.com/php/php-src/compare/master...morrisonlevi:php-sr= c:parameterized_traits >>=20 >>=20 >> I=E2=80=99m also interested in this; it will help see branches like t= hese. >> Did you ever get the POC working? What did you feel like was the bigg= est hurdle? > > There even was an RFC in voting which Joe implemented and it addresses=20 > nearly what is discussed it this thread https://wiki.php.net/rfc/array= of > > I must admit that the collection proposal is bit too complex to=20 > address such tiny but powerfully in my opinion functionality which is=20 > typed array. What Derick showed looks more like generic collection and=20 > such require declaring it's type. In my opinion this is way too mush=20 > hassle to declare as many collection types as many usages in=20 > application. Also two collection types with the same collection item=20 > type will not be compatible from type perspective. While typed array=20 > seems much more clear and compatible in all places where typed array i= s=20 > needed without declaring separate type for each usage. > > If I were to choose between typed-array and collection like Derick=20 > showed a little bit I'd choose typed arrays definitely as a first=20 > feature to be merged into PHP. > > Cheers, > Micha=C5=82 Marcin Brzuchalski Contextual point: Nearly every other major language at this point that h= as a meaningful standard library has gone with a three-separate-object a= pproach (Seq, Set, Dict, called various things). At least Python, Javas= cript, Rust, Kotlin, and Swift, in my research. (Go doesn't, but Go avo= ids having features by design.) And AFAIK *every* language except PHP a= nd Lua separates sequences from dictionaries. Typed arrays will not ful= l resolve the seq vs dict problem, which is arguably PHP's original sin.= And there's a lot of weird issues to resolve around what the syntax co= uld even be, since PHP has untyped variables. The custom collection syntax Derick has been working on is a second-best= alternative to generics, essentially. It is less ergonomic, no questio= n, but can also be implemented without generics, and so is about 5x easi= er to do. If we could get native generics, then I think everyone involv= ed agrees building collections off of that -- in essentially the same wa= y as every language I mentioned above --- would be preferable to a custo= m one-off syntax. --Larry Garfield