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 ; 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 ; 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: 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 ; Wed, 26 Jun 2024 23:31:33 +0000 (UTC) Received: by mail-io1-f45.google.com with SMTP id ca18e2360f4ac-7f3c878d6d4so89624939f.0 for ; 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 (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: 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: Wed, 26 Jun 2024 17:30:03 -0600 References: <6D0733B2-A1D1-45EC-B93E-029B1616A22F@miles.systems> <682DAE9D-7C53-4C2B-9ECF-9B8358DF0AA1@php.net> To: php internals In-Reply-To: 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 = wrote: >=20 >> We've done some initial work related to this as part of PHP = Foundation work: >> = >=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 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
) Articles {} >=20 > or just=20 >=20 > Dict
Articles {} > Seq
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
{} >=20 > If I'm not then it should read more like the following: >=20 > $a =3D (Dict
) []; >=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 { > public T $array =3D [=20 > =E2=80=98a=E2=80=99 =3D> =E2=80=98hello=E2=80=99 > ];=20 > } >=20 > $a =3D new A; >=20 >=20 > Best, > Richard Miles --Apple-Mail=_C82D5D5A-6160-4E85-AE7E-D23E93EB189C Content-Transfer-Encoding: quoted-printable Content-Type: text/html; 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=AFP= M, Richard Miles <richard@miles.systems> wrote:

We've done some initial work related to this as part of = PHP Foundation = work:
<https://github.com/derickr/php-src/tree/collections/Zend/test= s/collection>

After reviewing the PR I don't = think this accurately captures what we're attempting to do/discuss. =
Are there other branches you could share? You=E2=80=99ve posed a lot = of new syntax. I have questions.

collection(Dict) = Articles<string =3D> Article> {}

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? =

collection(Dict<Article>) Articles {}

or just =

Dict<Article> Articles {}
Seq<Article> Articles = {}

and then there's the completely new syntax? Am I supposed to = be able to add methods in this block?

class Articles extends = Dict<Article> {}

If I'm not then it should read more like = the following:

$a =3D (Dict<Article>) = [];

____________________________________________________________
But this all feels off-topic. Because, we need to get Typed Array = syntax!


interface iArrayA ['a' =3D> string ]
interface = iArrayB implements iArrayA ['b' =3D> string, 'c' =3D> ?string = ]


$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'
];

// 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.

class A {
=  public iArrayB $array =3D [
=E2=80=98a=E2=80=99 =3D> = =E2=80=98hello=E2=80=99,
=E2=80=98b=E2=80=99 =3D> = =E2=80=98world'
];
}

If generics and = the is operator get passed then one could in theory do.

class A = <T is iArrayA>{
=        public T $array =3D [ =
= = =E2=80=98a=E2=80=99 =3D> =E2=80=98hello=E2=80=99
]; =
}

$a =3D new A<iArrayB>;


Best,
Richard = Miles

= --Apple-Mail=_C82D5D5A-6160-4E85-AE7E-D23E93EB189C--