Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124135 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 9FC581A009C for ; Mon, 1 Jul 2024 12:21:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719836594; bh=Xm3ZzZ1ouv54GjHHnV+uuAUotgCi/VnyWHZqSICaok4=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=LqUdwZva1KaiMsNM786u1UJQWBGwWe22mliAGs2MMOIcNKTpocbf6T3KU4DWvZYEN 7V5OwD86APVOVNkvX661K/UU3x0EAGmp11t3iQqBFoBB0h4omG3qypqoF7vbPFBfGI 52DKSIg3p3O4rud+96L7uZKv0++j26zhYWB9y4l5Ki882vG9z00P82F8tc/VpG8QGV dq4ogHS/IFdFbATTY+egzaCYbepqJmLm3pS2Ya6lfcTr4vGPKlvBcq+Ku0TVwKmjWM pObqWdvHT5u2JcETwYLrD0phTC0l7+jTB0N26H0QUWgzdk1QX/o6MtKeSGm6Hc+005 ThY8U24CqNP7w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E5D9118059E for ; Mon, 1 Jul 2024 12:23:13 +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-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) (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 12:23:13 +0000 (UTC) Received: by mail-il1-f179.google.com with SMTP id e9e14a558f8ab-3737dc4a669so12058425ab.0 for ; Mon, 01 Jul 2024 05:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=miles.systems; s=google; t=1719836511; x=1720441311; 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=tNRPRUYv7dolCVdyuJKws6xEGUX49DZ44/0/6ebsqTA=; b=HNh8yHjGckMqNsXS4YLFVsqUEhtVJ8xF+LFnQJL4G3d1NKzKrKAdUZYYqBnfvSy88d a/cMZi/HB2CIfpFQP3GoG5rlkX3WWEz7EFyyQo3G7zzwFlSvE6bgh+wX7OwCRC/KfgkC FkUqOUhdCS8T6IcmWgn4nkv8+OJ4xOyJJcWLspUJaYeKHAK94Hs0LajJMpD4PFYPQNCX 4kdqDtBLJZ9BWqDJk+dtiDRomnk3XtL0LQZVDlUWCjShJ9KAn9HjRICCnnz3LjGp00kt OZXu2eOOJLo3Z9upv621GIoRxBENWpP/s83r6GdXPjzCfXrHMTg9W6Mp8aPwAA1KflGW htcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719836511; x=1720441311; 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=tNRPRUYv7dolCVdyuJKws6xEGUX49DZ44/0/6ebsqTA=; b=v5uxWGSx0h0rqBaHCtkRXIXT1N4c1SxmskGQ5PsXFCwhSQlEp6xYtW87rIVYeVLqzN Ps8cdok2y2cgLS/+0Ea7eUM/lGhb+j6epUNIudjF8/0HDaF6smYg6KgpDnh87meVvP60 BmwHGyFNJInDDQU8EFydWkBqadKFaccs0Zt8wByW6LhquDS8u/kt1Kk3E57oSs7JHApR jGPSEH+7Lw6UC26+uGzjcUqxLF9XOGnOQ8vQhncT8MofOFQpQao7MmxpOYYlaRkBHE2L IXQcO4B4GoavOfeVsTJu1LbgAgE5KT4GRNqvbc/zl88P43lzn0zDQsQQ0Muc3ACyHYDq TOrQ== X-Gm-Message-State: AOJu0YzP/ieFrOv70acaDGwLoZ2jTtNiqTMqi9EW3hNw4WsF6CkOPowh OVv6C+wqGeGYVGr11WVKz/+tj8P9hqvcFmu7fhFpCORz1Dcr0qDUQhB4yFUIQbZZ3C4QC+pMZz1 Mw1z9bLJc7pw42Td00UvvTtKE0wGllBWUScLWuSoVhwERaVdLwXRklj+lubQASRCUaGHZAzl6O6 JUwPGlmMQcbnnix87BbUAtSyNWxdeoR7vwsgShveK891Y= X-Google-Smtp-Source: AGHT+IHfGXyKTs9oEPbiKM9HUMAPmd8D1k8qxyKd3H2TAXVD/WPgxMAB03g2AMl5/L0L0hxlFUd5EQ== X-Received: by 2002:a05:6e02:1522:b0:374:70ed:d765 with SMTP id e9e14a558f8ab-37cd10d2addmr63913615ab.3.1719836507171; Mon, 01 Jul 2024 05:21:47 -0700 (PDT) Received: from smtpclient.apple ([2601:283:4600:6770:bc64:9d6d:433:900e]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-37ad483bc44sm18159975ab.78.2024.07.01.05.21.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jul 2024 05:21:46 -0700 (PDT) Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_116716B7-62BA-481D-B97E-4ED9F5079739" 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: Mon, 1 Jul 2024 06:21:35 -0600 In-Reply-To: Cc: Rob Landers To: php internals References: <07A8534A-1B45-4F15-A78B-AA7DDF92B8B6@koalephant.com> <5BA404A4-7281-475F-A1F6-D1252ABB059D@miles.systems> X-Mailer: Apple Mail (2.3774.600.62) From: richard@miles.systems (Richard Miles) --Apple-Mail=_116716B7-62BA-481D-B97E-4ED9F5079739 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Howdy Rob, >> I appreciate your feedback, and I think it=E2=80=99s valid. I try to = compare my expectations to what is possible in typescript. >=20 > 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 are 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 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. >=20 > 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 haven=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 written 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 starting point may be to simply propose an RFC about = syntax so future RFCs can be consistent.=20 >=20 > =E2=80=94 Rob I actually did not know it was turning complete, very interesting! While = it is easy for anyone to say, =E2=80=98we're not even close to = typescript,=E2=80=99=20 that=E2=80=99s precisely what brings me to the table. I would be happy = with us just voting on syntax. It seems like past RFC=E2=80=99s only=20 ever got hung up on generics (wrongfully?). I want to work on = implementing generics, too, after this. I feel this is probably a good=20= stepping stone.=20 A vote would solidify the following: interface iArrayA ['a' =3D> string ] interface iArrayB extends iArrayA ['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 ] $array =3D (iArrayA &| iArrayB) [ =E2=80=98a=E2=80=99 =3D> =E2=80=98hello=E2= =80=99 ]; That would allow us to move into an implementation discussion, which is = also absolutely needed.=20 Best,=20 Richard Miles=20= --Apple-Mail=_116716B7-62BA-481D-B97E-4ED9F5079739 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Howdy = Rob,

I = appreciate your feedback, and I think it=E2=80=99s valid. I try to = compare 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://gith= ub.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 are = 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=99= t 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 haven=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 written 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 starting point may be to = simply propose an RFC about syntax so future RFCs can be = consistent. 

=E2=80=94 = Rob

I actually did not know = it was turning complete, very interesting! While it is easy for anyone = to say, =E2=80=98we're not even close to = typescript,=E2=80=99 
that=E2=80=99s precisely what = brings me to the table. I would be happy with us just voting on syntax. = It seems like past RFC=E2=80=99s only 
ever got hung up = on generics (wrongfully?). I want to work on implementing generics, too, = after this. I feel this is probably a good 
stepping = stone. 

A vote = would solidify the following:


interface = iArrayA ['a' =3D> string ]
interface iArrayB extends iArrayA ['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 ]
$array =3D (iArrayA &| iArrayB) [ =E2=80=98a=E2=80= =99 =3D> =E2=80=98hello=E2=80=99 ];


That would allow us to move into an = implementation discussion, which is also absolutely = needed. 

Best, 
Richard Miles 
= --Apple-Mail=_116716B7-62BA-481D-B97E-4ED9F5079739--