Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124117 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 E43261A009C for ; Sun, 30 Jun 2024 23:11:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719789155; bh=lHPi1U/+fcsnE+u89LbI7/H2xWO3Wb0tjEpBoNkE/MU=; h=From:Subject:Date:References:To:In-Reply-To:From; b=EY8xXtDIled06nMOyFQapQPnVGcgRrTsh7Z/Vvx4C4x3riJ2GFGuQ+Ozj7iFPwdiI hvL2f0T+YgKSf5tucwFAiSoJ3vj0M3M3LgafYh35IdoBSpmQ0IF2r5tJOKc3NO2Uc7 G4pcd/8Lr7i1BniVRo4hes9gPikd8/tiLMNp3q7jum2uF1vLcFEWmmBlEUZGc84f55 okdS+Q8GZYKPIaUu4GQaRyD0d9QFVQKUKsDD+68YFrhnhbtKhE4QJcdOc8i4xMl3+S +rNaZJznkHBeLLRjYA0r2CbCJnQGSh6LGwqbpp9FNjR/zOzV7FTXYHT5Gxjt0Ba5eK +0dm01cXGWaMQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 038181807F1 for ; Sun, 30 Jun 2024 23:12: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-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 ; Sun, 30 Jun 2024 23:12:33 +0000 (UTC) Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-7eba486df76so62121139f.0 for ; Sun, 30 Jun 2024 16:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=miles.systems; s=google; t=1719789071; x=1720393871; 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=sliHNzMPTPTFn89Kp7D8EjZme5sIvCOdDYKX72RFqOQ=; b=Jncq9s3Sm2/xTLhqGY2ISrRnJL9iGjMNyraVTnzD6BEkeV7ubP25rYxK+dXt0IpkpX 5cdxJpo5ow/wx9f1+v0njhnIy/yQCMCm21TK6ZuhSrbzacYfmih3sdTF3gxZutCLj5Yc jHktTpwuBs4n9tOFmt1RTyhY39khDeKGFxQzdoJB/2htKsNHRvMj7Jcr5H98aBK8a2Vw rPqcMXgc2GiVUC5vV+C4J2CU9yZel9cRDPHrdKEZ6wLJzGamdFdx5dFbUNJ/wAfzaHII DC2XSEQEBGi7HfhWezRq7WrN44p+wwPa9t2aCLG28T/+JNtx5Mrf7G7XWVLKsITvCaaM raZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719789071; x=1720393871; 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=sliHNzMPTPTFn89Kp7D8EjZme5sIvCOdDYKX72RFqOQ=; b=a5Wc/4dbGfnGb+dcb+SFNX/23q2Gpb29ncKVhSA39OqihyYn08Ky7/oHROv0/ryPFM 29YFkw4Rw03/+IUZuJZgAB9PbbsTauGJvlNEk2XBigDnSaFA6RslA46ap1wo3elGzMOZ 8nybvWaZKp49m2bETGNCmvqz4hzT+15BmTs9DbBO1ktOy0T3yBWG4BqMKoyFxzTnon0F nPe98IMKYnQa9kikJJh/erzGE0oDPBHUpRhCEkNC85q1G2A+juBVyw5qQFqdvv7eFS6s /QGFz1C8Dw1/RnUIqc95qDOC9xEeWQPZHUJBdc4dX3g+x9GipLVYKywE1hgEbr+7lJMG EH9A== X-Gm-Message-State: AOJu0Yzwi0/vmIq/+u8NqV6nzmE9yWtfznGmE2Yu0TV7Xcp9+R+PsTJc WJsT4QhGeRO1SuI7wdtQbi82JTsF4q4sGgImLJiT4RutnpRY2lXje+rq+tuZS2SNfqsPreadlC4 YU9uf5DzRyIMWfAfpjsfxsYUG6B1uuD+Wn2ia6EhcsNIUAUrE+2fq6mYXY7kmgxKlkovbYnuykO qeFjNM7MFs6upLx5BplDJutD+e4zCqSiu+P0PoBhs4 X-Google-Smtp-Source: AGHT+IFuhghCJ5tuq/Lvm2KDlNhyr5k/74ZP3Zwx4OoEb5ioVF5OWGCsyN8JKDCbvkeNviPM7/hUBw== X-Received: by 2002:a05:6602:b81:b0:7f3:9d77:d24e with SMTP id ca18e2360f4ac-7f61f4b3549mr414159739f.1.1719789071153; Sun, 30 Jun 2024 16:11:11 -0700 (PDT) Received: from smtpclient.apple ([2601:283:4600:6770:bc64:9d6d:433:900e]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4bb73e08a13sm1853264173.84.2024.06.30.16.11.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Jun 2024 16:11:10 -0700 (PDT) Content-Type: multipart/alternative; boundary="Apple-Mail=_8A4E7297-CC77-4F7B-B76D-1CD87BE310A8" 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 17:10:59 -0600 References: <4ECBB519-B129-426F-93AE-33738A1ABA06@miles.systems> To: php internals In-Reply-To: Message-ID: X-Mailer: Apple Mail (2.3774.600.62) From: richard@miles.systems (Richard Miles) --Apple-Mail=_8A4E7297-CC77-4F7B-B76D-1CD87BE310A8 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 >> If I were to choose 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 indeed. I=E2=80=99m still looking for a karma sponsor ;) > Tuples are nice because they are bounded, they can probably act like = arrays =E2=80=A6=20 I=E2=80=99ve been leaning toward this working under the hood like = SplObjectStorage and SplFixedArray.=20 For those who may not be super familiar, I=E2=80=99ve added the PHP = documentation links: https://www.php.net/manual/en/class.splobjectstorage.php=EF=BF=BC https://www.php.net/manual/en/class.splfixedarray.php=EF=BF=BC A typed array would/may not be a hash table, but a fixed list of some = kind. I=E2=80=99ve had a few suggestions and one individual in the `is` operator conversation said hash tables = may be appropriate anyway.=20 Time will tell on this front and its implementation is worth the open = discussion. What should be absolute=20 is that arrays with a =E2=80=98fixed=E2=80=99 type maynot assign members = whoes types are not strictly defined. Thus, typed=20 arrays are stictly bound. SplFixedArray acted like numeric Seq<> whereas SplObjectStorge adds = functionionallity to our normal=20 arrays and acts our Dict<>. I think a big issue this proposal solves is how to syntactically = approach saying a member is present or null=20 or if member is present it should only be a string. The initial proposed = syntax in the early feedback of the=20 pattern matching rfc poses: > So yes, `[?'foo' =3D> string]` and `['foo' =3D> ?string]` are indeed > different.=20 A lot of discussion around this, but I think with interfaces this = becomes trivail. Note my example code sovles this using operators we already have: &, |, &| interface iArrayA ['a' =3D> string ] interface iArrayB implements iArrayA ['b' =3D> string, 'c' =3D> ?string = ] // reads the same as a typecast $array =3D (iArrayA &| iArrayB) [ =E2=80=98a=E2=80=99 =3D> =E2=80=98hello' ]; > =E2=80=A6 (possibly even cast to them and vice-versa). The way I implemented declaring types is actually just a typecast, so = perhaps that should change or=20 we just extend the current array implementation to hold another metadata = field.? Best, Richard Miles --Apple-Mail=_8A4E7297-CC77-4F7B-B76D-1CD87BE310A8 Content-Type: multipart/related; type="text/html"; boundary="Apple-Mail=_42CAB739-BCB1-4763-8313-6EB71CB01E07" --Apple-Mail=_42CAB739-BCB1-4763-8313-6EB71CB01E07 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
If I were to choose 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= indeed. I=E2=80=99m still looking for a karma sponsor = ;)

Tuples are nice because they are bounded, they = can probably act like arrays = =E2=80=A6 

I=E2=80=99ve been = leaning toward this working under the hood like SplObjectStorage and SplFixedArray. 
For those who = may not be super familiar, I=E2=80=99v= e added the PHP documentation links: