Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124114 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 3EC801A009C for ; Sun, 30 Jun 2024 16:45:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719765997; bh=XPhWnguoobbpXkNr2+AzLhwS0zzf7uoat2b7d/w/xi4=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=Qsh8J+NRXvpvFepBx423mYutrsW8xZi3+Xlbkx0GICXaIE0fsHYAQ9ToIwHB/znaP hyHrot9f3Sa/ESHNG1I4awY6ttbB6m6+fZ4wJM1wY1mCNTLTq9I7ixkJn49384EHYH xM+nDzHyBF7U6FxjiGEiOVuVR8m/g1fWkuLPhnd7KpEuDgSqND+bM3EEk5aoVsjmKP zqyr3bW3NhTh6BqtfTnDkFOLQf+UrM8q8t4VguTAlNZRtVyGEdDcaeOFLJK5PUJjNe guk5yyQZH3tlN9wAsMjTMMxJ+F5mz4NlMED1tmOMIdeuU1SjrKaSrlF87OvW9/Knqu /E5q9p8yMyOmw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 48192180CE8 for ; Sun, 30 Jun 2024 16:46:34 +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,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, 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 fout5-smtp.messagingengine.com (fout5-smtp.messagingengine.com [103.168.172.148]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 30 Jun 2024 16:46:33 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.nyi.internal (Postfix) with ESMTP id 6EB281380180; Sun, 30 Jun 2024 12:45:13 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute1.internal (MEProxy); Sun, 30 Jun 2024 12:45:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:cc: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=fm3; t=1719765913; x= 1719852313; bh=XPhWnguoobbpXkNr2+AzLhwS0zzf7uoat2b7d/w/xi4=; b=Q hNJov7hsqUmyWCIzZE3SOir8CGz++4r6GcyN++KdWDXBbn6KNLSTSIgJoxA6VxMu FbnW5fMaT2/Dwwt3/CJlDkJkO17VHWBacmRS123HIfQsGFuSZhXx2QIPPRVh5qye hqDd9Onosz31tvBHeWfwYRv9Ok7PSQ4XquWLPGTchZkRVtSJln4BhKAeVOgKvvSH KfSCSMjTvT0TIB7YmPbXCvYeVcmt8AK4dLA8m+oiMzlWA9iIdnpJ3kp5VtBSDpvu Wyxfr+iUEXFAkjX/hs7NNO9xUusAZtWOY2y658cK/yuorl3XI0q0Wzu65o7Z/ZjY ucECs1T7VSeqFyic4lQbg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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=1719765913; x=1719852313; bh=XPhWnguoobbpXkNr2+AzLhwS0zzf 7uoat2b7d/w/xi4=; b=LyL8myJZ8BpigNHS/T5H8fY0/j+C2GcUketwatbOFfaB FbhN0LKPg/fmt3Jl+QWDdbv470DcHUqXV6rE4zlq38KJSK8eLVZ9zzNckNBQiow1 2OR9zPqPQ8dFmbuIU3e3/9QC2Do3/F94jdZB4xWOyd1uAYi15hrXaY+OHqSjcwDt 1K8NH7LDKOVVzGihVQ+WFCqlmXuvYjk3yglSquODiu6eeUCZlC3Gz6SUqrIs3t07 nncjILKoKrcO3EgSbKVqqbu6SHN3+l6P/LOdXOiZFAcPCHLPBqF7KagBztiByhpl 72A0PXwKZV7s9azNEz9poMPwXdrteReamPafjFr7WA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddugddutdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsegrtderreerreejnecuhfhrohhmpedftfho sgcunfgrnhguvghrshdfuceorhhosgessghothhtlhgvugdrtghouggvsheqnecuggftrf grthhtvghrnhepgfekffegteekfefhjeefffevffejvddtudegueejjeevvdfgiedtgffg udevieejnecuffhomhgrihhnpehgihhthhhusgdrtghomhdpphhhphdrnhgvthenucevlh hushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohht thhlvggurdgtohguvghs X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id D51F915A0092; Sun, 30 Jun 2024 12:45:12 -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: In-Reply-To: References: <4ECBB519-B129-426F-93AE-33738A1ABA06@miles.systems> Date: Sun, 30 Jun 2024 18:44:51 +0200 To: =?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?= , "Richard Miles" Cc: "php internals" , "Derick Rethans" , "Levi Morrison" Subject: Re: [PHP-DEV] [Initial Feedback] Typed Arrays Content-Type: multipart/alternative; boundary=44f1ed816e454b65a00f03a6bb628668 From: rob@bottled.codes ("Rob Landers") --44f1ed816e454b65a00f03a6bb628668 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sun, Jun 30, 2024, at 18:13, Micha=C5=82 Marcin Brzuchalski wrote: > Hi Richard, >=20 > czw., 27 cze 2024, 22:33 u=C5=BCytkownik Richard Miles 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? >=20 > There even was an RFC in voting which Joe implemented and it addresses= nearly what is discussed it this thread https://wiki.php.net/rfc/arrayof >=20 > I must admit that the collection proposal is bit too complex to = address such tiny but powerfully in my opinion functionality which is ty= ped array. What Derick showed looks more like generic collection and suc= h require declaring it's type. In my opinion this is way too mush hassle= to declare as many collection types as many usages in application. Also= two collection types with the same collection item type will not be com= patible from type perspective. While typed array seems much more clear a= nd compatible in all places where typed array is needed without declarin= g separate type for each usage. >=20 > If I were to choose between typed-array and collection like Derick sho= wed a little bit I'd choose typed arrays definitely as a first feature t= o be merged into PHP. >=20 > Cheers, > Micha=C5=82 Marcin Brzuchalski=20 >>=20 Hello again, I=E2=80=99ve been thinking about this off-and-on. One of the issues brou= ght up in this thread around type-checking arrays is their unboundedness= , and the performance implications of that. Instead of typed arrays, why= not start with typed Tuples?=20 Tuples are nice because they are bounded, they can probably act like arr= ays (possibly even cast to them and vice-versa). I=E2=80=99m imagining something like (to borrow from another RFC): function bcdivmod(=E2=80=A6): Tuple which can be destructured just like an array. From the perspective of us= erland, they are bounded, typed arrays. =E2=80=94 Rob --44f1ed816e454b65a00f03a6bb628668 Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable

=
On Sun, Jun 30, 2024, at 18:13, Micha=C5=82 Marcin Brzuch= alski wrote:
Hi Richard,

czw.= , 27 cze 2024, 22:33 u=C5=BCytkownik Richard Miles <richard@miles.sys= tems> napisa=C5=82:

> I worked with J= oe Watkins to do a proof-of-concept for generic traits.
&= gt; It's a bit old since it's from 2017, but could be a useful starting<= br>
> point if you are serious about pursuing this idea:
>
> https://github.com/php/php= -src/compare/master...morrisonlevi:php-src:parameterized_traits
<= /div>


I=E2=80=99m also interested i= n this; it will help see branches like these.
Did you eve= r get the POC working? What did you feel like was the biggest hurdle?

= There even was an RFC in voting which Joe implemented and it addresses n= early what is discussed it this thread https://wiki.php.net/rfc/arrayof

I must admit that the collection<D= ict> proposal is bit too complex to address such tiny but powerfully = in my opinion functionality which is typed array. What Derick showed loo= ks more like generic collection and such require declaring it's type. In= my opinion this is way too mush hassle to declare as many collection ty= pes as many usages in application. Also two collection types with the sa= me collection item type will not be compatible from type perspective. Wh= ile typed array seems much more clear and compatible in all places where= typed array is needed without declaring separate type for each usage.

If I were to choos= e between typed-array and collection like Derick showed a little bit I'd= choose typed arrays definitely as a first feature to be merged into PHP= .

Cheers,
Micha=C5=82 Marcin Brzuchalski 


Hello again,

I=E2= =80=99ve been thinking about this off-and-on. One of the issues brought = up in this thread around type-checking arrays is their unboundedness, an= d the performance implications of that. Instead of typed arrays, why not= start with typed Tuples?

Tuples are nice = because they are bounded, they can probably act like arrays (possibly ev= en cast to them and vice-versa).

I=E2=80=99= m imagining something like (to borrow from another RFC):
<= br>
function bcdivmod(=E2=80=A6): Tuple<int, int>

which can be destructured just like an array. Fro= m the perspective of userland, they are bounded, typed arrays.

=E2=80=94 Rob
--44f1ed816e454b65a00f03a6bb628668--