Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123905 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 E3EC81A009C for <internals@lists.php.net>; Wed, 26 Jun 2024 23:30:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719444694; bh=jL06kiTcXYjL4zPTBEs6zhkUC0/oDbUnumQ1WwEzAf8=; h=From:Subject:Date:References:To:In-Reply-To:From; b=QUE9GTvITGiOunLBApx5x5cufUIdpvyER1EH8RYFdIQy4KZ+8AOTx6onRTUD4vxpF iPzFq0U34pggzWN6Wp2TWcmiSknBmsCZJ1ODPonh9MzRBH6cILirRnOf7mVZhmTMiN 0J3qUPQEsI9iQNPq+9WUmuFH8VqLmRTvspiy4xa/p3ncERMSyCQnkUgd93k2Xrr36U UVtCEfwYQYDfF3U64xBc5gqKsOy651E5y0far6MdZC5E+0PFOQjQBYA40m5TsWnhbM c1vGNPEAFWGWcIAIS2zVeK5iHdAmemoE5woIMQFerDN0kIu0jhG3OvlHks1xkLgz0x 0080+c7FF7JDw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0E2E1180AF3 for <internals@lists.php.net>; Wed, 26 Jun 2024 23:31: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.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: <richard@miles.systems> Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) (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 <internals@lists.php.net>; Wed, 26 Jun 2024 23:31:33 +0000 (UTC) Received: by mail-io1-f45.google.com with SMTP id ca18e2360f4ac-7f3c878d6d4so89624939f.0 for <internals@lists.php.net>; Wed, 26 Jun 2024 16:30:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=miles.systems; s=google; t=1719444614; x=1720049414; darn=lists.php.net; h=message-id:in-reply-to:to:references:date:subject:mime-version:from :from:to:cc:subject:date:message-id:reply-to; bh=oYKUStBvLYTEkx/a3/fGNZZ+DfRnCoS28wLIpiQRJ3U=; b=C0svoOmNqofsKO6d2SCUsgpU1IxthH8fI/2sD5F9zkmhzBnU+DW6/toBwzDhHDBPUY gdYBTzYvsG4CCxPanG+3UI8OZhKnVJsgEnEK7GRerXjOs10aO1TLTKuLVzOLvNG0yn3K A6fmX3dxTso6G1yVMyUvQBA72yIHZ25ggpLLD2TQXr8uojYY7y5L+FTHNA1fnGieLXm9 UN+de9ls64A7uOg9G0dewu52857dcTTciYAjzwWdIJv3bR3/HRSj4mD4eY5+VaHVAt1q y+z127vmuzQlnorHzYBODTNxjJ+9TloPD3JUJqV50a3qIz3hg9mILfLJDUe8FTpwdJSJ dY2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719444614; x=1720049414; h=message-id:in-reply-to:to:references:date:subject:mime-version:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oYKUStBvLYTEkx/a3/fGNZZ+DfRnCoS28wLIpiQRJ3U=; b=hFIXLLVJhN0K5werDjLemyMDLcHMb9pqHlmOFY97c4bTemrD4gtinErTlCqgDEwYmd bRPUPtbGfUcWektfSdRZvRJmgKc2jXwvIwLT9xnIFOT7X6o5OMfWMGZ8GIiMc788q6PT rP/b8QJU+q+I8UW/X0TBwcUuSGaLTuiZY+22emRr+M32kJidgQC/zApTGvshca/6408J QDt9jJZ5UKyML16J0q4bN3tUgzzr0tS0MzcKeVlJCmzTH+PUnKpBP8T/RI5Hg9uIhiMu waQdYwEaFknY7raKR7vg8rMOPTYGnLy6HzhYBSNqw/htkAZEmOFHKu5KDpxCJTKZVv8k rtfg== X-Gm-Message-State: AOJu0YzwV0ZhHpXAPkCN21KEg7Qx8oNHR9W5QXSfnShuz8PZgdbQRIC0 Mj4swaVSBqzO7Pp0s98tonTOD5SOhck4sF/GgcTvCh+AxshsynZasAZa9RExYqumpFYcfgY4lVD +MKpfh/0iGt500QPxfSewFmyujTLrn5g0YQqbhcmi5YhmPqZSeT0i6WG275eQs0uoXrlcnq1GOm tAnHYX4YK3xIm7lD0iCw+pj1WpTTsfDGUPoGJccCm1 X-Google-Smtp-Source: AGHT+IEd6WnsTCkMQLJ78aXAh0x2//f5NcuGxfYd6l5CxMnn0k3xFKPDYbiuqNqnc73lPn5LVhAIQw== X-Received: by 2002:a05:6602:1352:b0:7eb:9a46:c743 with SMTP id ca18e2360f4ac-7f3a4dc3c56mr1715158639f.7.1719444614370; Wed, 26 Jun 2024 16:30:14 -0700 (PDT) Received: from smtpclient.apple ([2601:283:4600:6770:1058:1c9c:6c8b:173a]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4bb665a3d3csm45675173.152.2024.06.26.16.30.13 for <internals@lists.php.net> (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jun 2024 16:30:14 -0700 (PDT) Content-Type: multipart/alternative; boundary="Apple-Mail=_C82D5D5A-6160-4E85-AE7E-D23E93EB189C" Precedence: bulk list-help: <mailto:internals+help@lists.php.net list-unsubscribe: <mailto:internals+unsubscribe@lists.php.net> list-post: <mailto:internals@lists.php.net> 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: Wed, 26 Jun 2024 17:30:03 -0600 References: <6D0733B2-A1D1-45EC-B93E-029B1616A22F@miles.systems> <682DAE9D-7C53-4C2B-9ECF-9B8358DF0AA1@php.net> <D49DD624-46EC-402E-BD63-053243BDBDBD@miles.systems> To: php internals <internals@lists.php.net> In-Reply-To: <D49DD624-46EC-402E-BD63-053243BDBDBD@miles.systems> Message-ID: <69CBCE02-0A07-4B9B-80B4-E2A1311E2642@miles.systems> X-Mailer: Apple Mail (2.3774.600.62) From: richard@miles.systems (Richard Miles) --Apple-Mail=_C82D5D5A-6160-4E85-AE7E-D23E93EB189C Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 I suppose you don't actually need the `is` op; you can use the = implements &| extends keywords :) Best, Richard Miles > On Jun 26, 2024, at 5:26=E2=80=AFPM, Richard Miles = <richard@miles.systems> wrote: >=20 >> We've done some initial work related to this as part of PHP = Foundation work: >> = <https://github.com/derickr/php-src/tree/collections/Zend/tests/collection= > >=20 > After reviewing the PR I don't think this accurately captures what = we're attempting to do/discuss.=20 > Are there other branches you could share? You=E2=80=99ve posed a lot = of new syntax. I have questions. >=20 > collection(Dict) Articles<string =3D> Article> {} >=20 > The code above is limiting compared to the posed syntax in this = thread. Since your just working on providing a specific datatype with a = custom syntax. What am I supposed to be able todo inside the {}? Why = not?=20 >=20 > collection(Dict<Article>) Articles {} >=20 > or just=20 >=20 > Dict<Article> Articles {} > Seq<Article> Articles {} >=20 > and then there's the completely new syntax? Am I supposed to be able = to add methods in this block? >=20 > class Articles extends Dict<Article> {} >=20 > If I'm not then it should read more like the following: >=20 > $a =3D (Dict<Article>) []; >=20 > ____________________________________________________________ >=20 > But this all feels off-topic. Because, we need to get Typed Array = syntax!=20 >=20 >=20 > interface iArrayA ['a' =3D> string ] > interface iArrayB implements iArrayA ['b' =3D> string, 'c' =3D> = ?string ] >=20 >=20 > $array =3D iArrayA [ > =E2=80=98a=E2=80=99 =3D> =E2=80=98hello' > ]; > // reads the same as a typecast > $array =3D (iArrayA &| iArrayB) [ > =E2=80=98a=E2=80=99 =3D> =E2=80=98hello' > ]; >=20 > // It=E2=80=99s essentially like a typecast, which should probably be = allowed. If the set of possible values needs to increase, a typecast = would do it.=20 >=20 > class A { > public iArrayB $array =3D [=20 > =E2=80=98a=E2=80=99 =3D> =E2=80=98hello=E2=80=99, > =E2=80=98b=E2=80=99 =3D> =E2=80=98world' > ];=20 > } >=20 > If generics and the is operator get passed then one could in theory = do. >=20 > class A <T is iArrayA>{ > public T $array =3D [=20 > =E2=80=98a=E2=80=99 =3D> =E2=80=98hello=E2=80=99 > ];=20 > } >=20 > $a =3D new A<iArrayB>; >=20 >=20 > Best, > Richard Miles --Apple-Mail=_C82D5D5A-6160-4E85-AE7E-D23E93EB189C Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 <html><head><meta http-equiv=3D"content-type" content=3D"text/html; = charset=3Dutf-8"></head><body style=3D"overflow-wrap: break-word; = -webkit-nbsp-mode: space; line-break: after-white-space;">I suppose you = don't actually need the `is` op; you can use the implements &| = extends keywords :)<div><br id=3D"lineBreakAtBeginningOfMessage"><div> <div dir=3D"auto" style=3D"font-family: Helvetica; font-size: 12px; = font-style: normal; font-variant-caps: normal; font-weight: 400; = letter-spacing: normal; orphans: auto; text-align: start; text-indent: = 0px; text-transform: none; white-space: normal; widows: auto; = word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: = none; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); overflow-wrap: = break-word; -webkit-nbsp-mode: space; line-break: = after-white-space;"><div>Best,</div><div>Richard Miles</div></div><br> </div> <div><br><blockquote type=3D"cite"><div>On Jun 26, 2024, at 5:26=E2=80=AFP= M, Richard Miles <richard@miles.systems> wrote:</div><br = class=3D"Apple-interchange-newline"><div><div><blockquote = type=3D"cite">We've done some initial work related to this as part of = PHP Foundation = work:<br><https://github.com/derickr/php-src/tree/collections/Zend/test= s/collection><br></blockquote><br>After reviewing the PR I don't = think this accurately captures what we're attempting to do/discuss. = <br>Are there other branches you could share? You=E2=80=99ve posed a lot = of new syntax. I have questions.<br><br>collection(Dict) = Articles<string =3D> Article> {}<br><br>The code above is = limiting compared to the posed syntax in this thread. Since your just = working on providing a specific datatype with a custom syntax. What am I = supposed to be able todo inside the {}? Why not? = <br><br>collection(Dict<Article>) Articles {}<br><br>or just = <br><br>Dict<Article> Articles {}<br>Seq<Article> Articles = {}<br><br>and then there's the completely new syntax? Am I supposed to = be able to add methods in this block?<br><br>class Articles extends = Dict<Article> {}<br><br>If I'm not then it should read more like = the following:<br><br>$a =3D (Dict<Article>) = [];<br><br>____________________________________________________________<br= ><br>But this all feels off-topic. Because, we need to get Typed Array = syntax! <br><br><br>interface iArrayA ['a' =3D> string ]<br>interface = iArrayB implements iArrayA ['b' =3D> string, 'c' =3D> ?string = ]<br><br><br> $array =3D iArrayA [<br><span class=3D"Apple-tab-span" = style=3D"white-space:pre"> </span>=E2=80=98a=E2=80=99 =3D> = =E2=80=98hello'<br>];<br>// reads the same as a typecast<br> $array =3D = (iArrayA &| iArrayB) [<br><span class=3D"Apple-tab-span" = style=3D"white-space:pre"> </span>=E2=80=98a=E2=80=99 =3D> = =E2=80=98hello'<br>];<br><br>// It=E2=80=99s essentially like a = typecast, which should probably be allowed. If the set of possible = values needs to increase, a typecast would do it. <br><br>class A {<br> = public iArrayB $array =3D [ <br><span class=3D"Apple-tab-span" = style=3D"white-space:pre"> </span><span class=3D"Apple-tab-span" = style=3D"white-space:pre"> </span>=E2=80=98a=E2=80=99 =3D> = =E2=80=98hello=E2=80=99,<br><span class=3D"Apple-tab-span" = style=3D"white-space:pre"> </span><span class=3D"Apple-tab-span" = style=3D"white-space:pre"> </span>=E2=80=98b=E2=80=99 =3D> = =E2=80=98world'<br><span class=3D"Apple-tab-span" = style=3D"white-space:pre"> </span>]; <br>}<br><br>If generics and = the is operator get passed then one could in theory do.<br><br>class A = <T is iArrayA>{<br> = public T $array =3D [ = <br><span class=3D"Apple-tab-span" style=3D"white-space:pre"> = </span><span class=3D"Apple-tab-span" style=3D"white-space:pre"> = </span>=E2=80=98a=E2=80=99 =3D> =E2=80=98hello=E2=80=99<br><span = class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>]; = <br>}<br><br>$a =3D new A<iArrayB>;<br><br><br>Best,<br>Richard = Miles</div></div></blockquote></div><br></div></body></html>= --Apple-Mail=_C82D5D5A-6160-4E85-AE7E-D23E93EB189C--