Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124126 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 B9EA11A009C for ; Mon, 1 Jul 2024 03:05:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719803205; bh=nsJJFGxo5LEazf+TRRCtyhPyELaKlZ1baa25cNzu4No=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=Ee2q50sfszQ2zCOb3InB8pI3dXjDAroOh/qAfVxDxRUo8zyyfeffXBYx8RFx47eH8 sH02P1xocHGN55TGm+aws2A3YttJ2ZtHt3c9/T7WiN4kwcGLIVvr4K5gOZS5tgHqe4 GMeisKqWGDoohpQSqXZLW7WexXlm0VuwTEiRW5lsCTuMKCDjqtTsFnPxAXVuImYF0d 8R2a9QZPHCSGxELgYsX7CXjZKyhJ5+HlNbo2x7bJ70tPeAzY6dZtYPtvbCYSxyfjg0 0Cw5Z7YXW7zZPdfGX75kNJONiD+UdFwqajJZJP3RO/Ubs3roAuyBdK8aGDT+VGe2YZ Bclq44jbQqfBA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 565FB180039 for ; Mon, 1 Jul 2024 03:06:42 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,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 mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) (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 03:06:41 +0000 (UTC) Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-7f3d37d6bfdso72496339f.1 for ; Sun, 30 Jun 2024 20:05:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=miles.systems; s=google; t=1719803120; x=1720407920; darn=lists.php.net; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=mv8LK1qYfZR0YodRuYD/ZhVbtxVJuoukU3eDHJfexQI=; b=ETd2V/bZGb6ZorrfXpmrgLlZAL4ccOpz2bBprg/VP4MKCWIQ3GrogUMYgrV9k1rHFR JEZWCYJ5xFVTOLgGo6+PueZrTt29NqwU/JyW42x7nz3OotGuJ/jWVZqRhORgCfF33WW9 zX1NmoRj/KbQjV+yAcNsz6VGVlSJOEwYlppP2HRnbU6yyZRo5FFd9UxZKK7iSjKi+KqU cFVgFvOyjelKvRkvXQSkAewQJQgT7peX5L5Ei7UiAPvtm6/gEbbQV5j62eHIC2AXh76B jeWEj8apk/psJ9U2ZFXQ8Xl6KQ++27Djx20UgpZRM1oSAHj5sCnukJW00k+++9LxG75q seSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719803120; x=1720407920; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mv8LK1qYfZR0YodRuYD/ZhVbtxVJuoukU3eDHJfexQI=; b=bp8u2XaH9mIMmhe0pLQuWb93f6AHlJ6AECjzxTXsf96c8/5TyCuk1mSXBTlePtVpkI a9BH6yJ1NgAtVHy1XCeaEtBCjGVcdMnmOhJ3W41VC69bP40G1v6hRX0nFksOdJeie/Md DfsYjPb7Q1thXnTU7z0E76/bKKtKqdsbaYbmR4Gq1+W2R7hKVq7Yj0qJ2yYNsq0EEJIb 1oNriJYJM7Rl/UREoSyyoLgWoqgvYb8/se2PuDdCojgswi4FeV6tsBBFHe9Ac6lWbi/d t6qRZJV3mQVzKEP3o9f8zTtz7u2J5viP8cOAh8zobOF5SghNJ830iomAiQiPk2UJ8/Hj Ts0w== X-Gm-Message-State: AOJu0YxCjjE8S4Y9hJORywmx9oX33YLewK60xBj8Em6V3GvXQdM2CabW MLIkL2lF34UlN79MZUhXxDoqYO1p0e+fUMMceuFL3nJiJpQimArzgTCqMae3ZIGXY2tf/qAkccr W9mUGqANXbVl4LDR6U3M3NdIvLv+dktSESviTE2oqZ9XxWlQpNQfvNpWpEvkIpD17kiroKcQEmh Vn2BRNR2FsIbjsx6AR0hJ4N29DbQa1PTy0eT53TXNl X-Google-Smtp-Source: AGHT+IEO5iHxET/82guc6jBAuUrKWr4AgmtthE00bFhcDNGgK/N+O0W3kqNYJhAMC7PRdO+2rKlmvg== X-Received: by 2002:a05:6602:3f4b:b0:7f3:9bdb:fe2 with SMTP id ca18e2360f4ac-7f62ee11a4fmr188187839f.2.1719803119704; Sun, 30 Jun 2024 20:05:19 -0700 (PDT) Received: from smtpclient.apple ([2601:283:4600:6770:bc64:9d6d:433:900e]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-7f61d0fe343sm171238939f.38.2024.06.30.20.05.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Jun 2024 20:05:19 -0700 (PDT) Message-ID: <5BA404A4-7281-475F-A1F6-D1252ABB059D@miles.systems> Content-Type: multipart/alternative; boundary="Apple-Mail=_1D5CBD57-A144-408F-BCE3-1F1D4D1197AC" Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: [PHP-DEV] [Initial Feedback] Typed Arrays Date: Sun, 30 Jun 2024 21:05:08 -0600 In-Reply-To: <07A8534A-1B45-4F15-A78B-AA7DDF92B8B6@koalephant.com> Cc: Stephen Reay To: php internals References: <07A8534A-1B45-4F15-A78B-AA7DDF92B8B6@koalephant.com> X-Mailer: Apple Mail (2.3774.600.62) From: richard@miles.systems (Richard Miles) --Apple-Mail=_1D5CBD57-A144-408F-BCE3-1F1D4D1197AC Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Howdy Stephen,=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 need = 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 = prevents it from being revived today? The whole "does it 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 feedback, 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.=20 While it=E2=80=99s true that PHP can take arrays and mash them into = objects, 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 bad = 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 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=20 me implementing this syntax, and who knows, maybe it will be awesome for = performance. I think what we should consider is that other=20 languages have this, and I feel the community wants this but is hung up = on generics, which may have been an oversight.? I=E2=80=99m pretty new=20= here, and I=E2=80=99d love to make a meaningful impact, so the fact that = this idea has been brought up before is encouraging.=20 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;=20 Maybe the signature for Dict is: class Dict {} Everyone harps on Generics, but no one can say how I'm supposed to model = 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 Best,=20 Richard Miles= --Apple-Mail=_1D5CBD57-A144-408F-BCE3-1F1D4D1197AC Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Howdy = Stephen, 

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

Hi

Given other = improvements in the language, I don't really see much need 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?)

Is there some fundamental aspect of the = original arrayof RFC that prevents it from being revived today? The = whole "does it 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 feedback, 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. 

While it=E2=80=99s true that = PHP can take arrays and mash them into objects, I have to ask myself if = this other language has this 
feature, why don't we? Is = it because 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, and who knows, = maybe it will be awesome for performance. I think what we should = consider is that other 
languages have this, and 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 that 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<string, iArrayA>; 


Maybe the = signature for Dict is:

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

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

Best, 
Richard = Miles
= --Apple-Mail=_1D5CBD57-A144-408F-BCE3-1F1D4D1197AC--