Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124131 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 2E0261A009C for ; Mon, 1 Jul 2024 06:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719817047; bh=pszr0fuU7icMcRtJouygPU1rxA6BH0cqOVQAFliy4ak=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=X+aeDefYq9/wSSrGOGouYq+VF/cu1l/CXrsBrsRyPwBuI6qnwZn8JVm6rAuCrhDCX bx3cLS2M0XVftfeanENLj7VmK7aCvIqIFzj+2OVwVKXg73KhU6VLFbOmfPi7Af7RbO lrvEzSkFDG1Iw0A3qo5SwsaMS5GRgSsAbCZu67ZTPG9325x/22OxHOsv8d5hdSU2jO PlbrxzMfFOvlZ802e5g31OVT+AQDMwWhjANxV4+C67wSKkk+i6FE36WYeLtA5JfTBu tFc0sgDdVgotWP8VMJ0RL+qiU1HH7Q3kkInpuq0ktDABsjVncsUGZMITwo5eH/M3nF RgKNuuERPFunA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6DE041805A4 for ; Mon, 1 Jul 2024 06:57:23 +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,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 fhigh3-smtp.messagingengine.com (fhigh3-smtp.messagingengine.com [103.168.172.154]) (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 06:57:22 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 132D711401B0; Mon, 1 Jul 2024 02:56:02 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute1.internal (MEProxy); Mon, 01 Jul 2024 02:56:02 -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=1719816962; x= 1719903362; bh=lCHr005ZKnExn/oUULevvthvgpxFVjjjbhLQ3iAwfmQ=; b=M N5tQ6h59D8qPxMKdUII4tLhjg+hnq7y8KkvY9wUOP/QoS5rIu2CJyJWmTm1Dgdnj 0L2nw463LnYFv8po7RwlDH/cNYQmMyB4ysmZYlLn3EvKNXNm5nOPMscNlK0X+nh0 3swDqnC2/QDRtXqtpmwqiZWzB3tTVPD0gBoxGMPbOnH7RnN4JNtz+Mf+1R26OB28 PTlbXSCV/8RvYYVCHmRtIWd9UiyhqTmCF6tPWv3W+EkSTN9BWR44XBybDkCZaeby +GVbfkbuNTfgHRHvFpGQQeaZFZE2gtpj8NWLqnL6En1W7N1ThRA8Tna06wfFLaX4 OMQbwEgCYO+g+mLPeZNww== 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=1719816962; x=1719903362; bh=lCHr005ZKnExn/oUULevvthvgpxF VjjjbhLQ3iAwfmQ=; b=aYu0hkkoSD6UOnyelRkzPHoXAW0cbJk0U9IUv1w5sjrv 790ncbI/9l7HZu604JxeGcoE7Hlg2MBH8tC6bGA3X4tGbn/gKGp0Cuvhl2m4K+B4 7V2uUoMi/+qx36ypbqYHHeQ+JdlVMGosfDmNot7vuvN3OYVojwu4Rk3T2tdF4WGk Xq47FBvbn3JVELjjdYDWD31J7v4+UduZF48AXUY6A1hm4IV1s5cqVO3Gz4FowTzU p4bc1cFmu1xP9tlkqg14y3XlykfJBgx1YucJmRwLegULSvjXh8VWZNYK3KHLbTuR 22LTP56nXnp6FcKzoFa6qD/q9cHpDiIMIajMFMwrtw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddvgdduuddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsegrtderreerreejnecuhfhrohhmpedftfho sgcunfgrnhguvghrshdfuceorhhosgessghothhtlhgvugdrtghouggvsheqnecuggftrf grthhtvghrnhepvdekleethfdvffduveeutddtuddtleetgfeugfejfeehieejvdegjeeu ueefvefgnecuffhomhgrihhnpehgihhthhhusgdrtghomhenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohhtthhlvggurdgtohgu vghs X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 7313215A0092; Mon, 1 Jul 2024 02:56:01 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-566-g3812ddbbc-fm-20240627.001-g3812ddbb Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: In-Reply-To: <5BA404A4-7281-475F-A1F6-D1252ABB059D@miles.systems> References: <07A8534A-1B45-4F15-A78B-AA7DDF92B8B6@koalephant.com> <5BA404A4-7281-475F-A1F6-D1252ABB059D@miles.systems> Date: Mon, 01 Jul 2024 08:55:40 +0200 To: "Richard Miles" , "php internals" Cc: "Stephen Reay" Subject: Re: [PHP-DEV] [Initial Feedback] Typed Arrays Content-Type: multipart/alternative; boundary=40ed06e018374f6090096fd0a1f9bcaf From: rob@bottled.codes ("Rob Landers") --40ed06e018374f6090096fd0a1f9bcaf Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable On Mon, Jul 1, 2024, at 05:05, Richard Miles wrote: > Howdy Stephen,=20 >=20 >>>=20 >>>=20 >>> It seems like everyone always gets really hung up on generics! That = or how to syntactically implement this. >>=20 >> Hi >>=20 >> Given other improvements in the language, I don't really see much nee= d for the ability to specify fixed keys and their types (ie associative = arrays) (I assume that's what the "['a' =3D> string]" syntax is meant to= be?) >>=20 >> Is there some fundamental aspect of the original arrayof RFC that pre= vents it from being revived today? The whole "does it include nulls" par= t is moot now presumably because we have both ? And |null, and the Type[= ] syntax is very common in docblocks. >=20 > I appreciate your feedback, and I think it=E2=80=99s valid. I try to c= ompare my expectations to what is possible in typescript. > This comparison, while not a perfect match, is a great source of learn= ing and inspiration.=20 >=20 > While it=E2=80=99s true that PHP can take arrays and mash them into ob= jects, I have to ask myself if this other language has this=20 > feature, why don't we? Is it because we don=E2=80=99t care? Is it a ba= d feature? I don't think so.=20 > I have a PR for WebSockets that integrates with Apache. Why hasn=E2=80= =99t it been done before? > I don=E2=80=99t think this is an oversight on others, but rather, the = community is what makes PHP better, challenging norms.=20 >=20 > I=E2=80=99m not saying it will outperform what objectiveness currently= provides, but I'm also not saying it won=E2=80=99t! I don=E2=80=99t thi= nk there=E2=80=99s a negative to=20 > me implementing this syntax, and who knows, maybe it will be awesome f= or performance. I think what we should consider is that other=20 > languages have this, and I feel the community wants this but is hung u= p on generics, which may have been an oversight.? I=E2=80=99m pretty ne= w=20 > here, and I=E2=80=99d love to make a meaningful impact, so the fact th= at this idea has been brought up before is encouraging.=20 >=20 > Take, for example: >=20 > interface iArrayA ['a' =3D> string, 'b' =3D> string, 'c' =3D> ?string,= =E2=80=98d=E2=80=99 =3D> SomeClass, =E2=80=98e=E2=80=99=3D> iArrayA, = =E2=80=98f=E2=80=99 =3D> mixed ] >=20 > $a =3D new Dict;=20 >=20 >=20 > Maybe the signature for Dict is: >=20 > class Dict {} >=20 > Everyone harps on Generics, but no one can say how I'm supposed to mod= el iArrayA if we focus on Generics.=20 > We cannot safely define this now, as iArrayA is not a valid interface.= I believe that is what I'm advocating for alone. =20 > Array interfaces.=20 >=20 > Best,=20 > Richard Miles Hello, > I appreciate your feedback, and I think it=E2=80=99s valid. I try to c= ompare my expectations to what is possible in typescript. I feel like Typescript is the wrong model to follow. The type system in = Typescript is Turing Complete (https://github.com/microsoft/TypeScript/i= ssues/14833) and php barely has a type system. It doesn=E2=80=99t even h= ave consistent type checking, for that matter (properties are checked di= fferently than arguments which are checked differently than constructor = arguments =E2=80=94 and the fact they agree with each other at all, is i= nteresting, because they don=E2=80=99t arrive at the same conclusions in= the same way. I=E2=80=99ve been dealing with subtle bugs here for weeks= on an unannounced RFC implementation) and this is why generics is a can= of worms: implementing it would essentially force a rewrite of the type= system into a proper type system. In my honest opinion, before we can even have this type of conversation,= we need to have an RFC about the syntax (there may already be one, I ha= ven=E2=80=99t checked =E2=80=94 and internet is spotty where I currently= am). The pattern matching RFC was proposed as though it would be writte= n one way, people have thrown out ideas of different syntax, but I don=E2= =80=99t think there is an =E2=80=9Cofficial=E2=80=9D syntax. A good star= ting point may be to simply propose an RFC about syntax so future RFCs c= an be consistent.=20 =E2=80=94 Rob --40ed06e018374f6090096fd0a1f9bcaf Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable

=
On Mon, Jul 1, 2024, at 05:05, Richard Miles wrote:
Howdy Stephen, 



It seems like everyone always gets really hung up on gen= erics! That or how to syntactically implement this.

Hi

Given other = improvements in the language, I don't really see much need for the abili= ty to specify fixed keys and their types (ie associative arrays) (I assu= me that's what the "['a' =3D> string]" syntax is meant to be?)

Is there some fundamental aspect of the original = arrayof RFC that prevents it from being revived today? The whole "does i= t include nulls" part is moot now presumably because we have both ? And = |null, and the Type[] syntax is very common in docblocks.

I appreciate your fe= edback, and I think it=E2=80=99s valid. I try to compare my expectations= to what is possible in typescript.
This comparison, while= not a perfect match, is a great source of learning and inspiration.&nbs= p;

While it=E2=80=99s true that PHP can tak= e arrays and mash them into objects, I have to ask myself if this other = language has this 
feature, why don't we? Is it becau= se we don=E2=80=99t care? Is it a bad feature? I don't think so. 
I have a PR for WebSockets that integrates with Apache. Why= hasn=E2=80=99t it been done before?
I don=E2=80=99t think= this is an oversight on others, but rather, the community is what makes= PHP better, challenging norms. 

I=E2=80= =99m not saying it will outperform what objectiveness currently provides= , but I'm also not saying it won=E2=80=99t! I don=E2=80=99t think there=E2= =80=99s a negative to 
me implementing this syntax, a= nd who knows, maybe it will be awesome for performance. I think what we = should consider is that other 
languages have this, a= nd I feel the community wants this but is hung up on generics, which may= have been an oversight.?  I=E2=80=99m pretty new 
here, and I=E2=80=99d love to make a meaningful impact, so the fact t= hat this idea has been brought up before is encouraging. 
=

Take, for example:

interface iArrayA ['a' =3D> string, 'b= ' =3D> string, 'c' =3D> ?string, =E2=80=98d=E2=80=99 =3D>  = ;SomeClass, =E2=80=98e=E2=80=99=3D>  iArrayA, =E2=80=98f=E2=80=99= =3D> mixed ]

$a =3D new Dict<s= tring, iArrayA>; 


Maybe the signature for Dict is:

class Dict<R is string | int, S is mixed> {}<= br>

= Everyone harps on Generics, but no o= ne can say how I'm supposed to model iArrayA if we focus on Generics. 
We cannot safely define this now, a= s iArrayA is not a valid= interface. I believe that is what I'm advocating for alone.  
Array interfaces. 

Best,=  
Richard Miles

Hello,

I appreciate your feedback, and I think it=E2=80=99s val= id. I try to compare my expectations to what is possible in typescript.<= br>

I feel like Typescript is the = wrong model to follow. The type system in Typescript is Turing Complete = (https:= //github.com/microsoft/TypeScript/issues/14833) and php barely has a= type system. It doesn=E2=80=99t even have consistent type checking, for= that matter (properties are checked differently than arguments which ar= e checked differently than constructor arguments =E2=80=94 and the fact = they agree with each other at all, is interesting, because they don=E2=80= =99t arrive at the same conclusions in the same way. I=E2=80=99ve been d= ealing with subtle bugs here for weeks on an unannounced RFC implementat= ion) and this is why generics is a can of worms: implementing it would e= ssentially force a rewrite of the type system into a proper type system.=

In my honest opinion, before we can even h= ave this type of conversation, we need to have an RFC about the syntax (= there may already be one, I haven=E2=80=99t checked =E2=80=94 and intern= et is spotty where I currently am). The pattern matching RFC was propose= d as though it would be written one way, people have thrown out ideas of= different syntax, but I don=E2=80=99t think there is an =E2=80=9Coffici= al=E2=80=9D syntax. A good starting point may be to simply propose an RF= C about syntax so future RFCs can be consistent. 

=E2=80=94 Rob
--40ed06e018374f6090096fd0a1f9bcaf--