Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125239 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 68C4C1A00BD for ; Sun, 25 Aug 2024 20:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724619582; bh=WAK4FcxONB9bt1KcXei4Ct9sAQUMuITH2/OYs/l2ecI=; h=Date:From:To:In-Reply-To:References:Subject:From; b=QyZkF3IeRET7UXF7hX28l1pZzkYT7fvoHDkuP7Xsr3BRc8grHGHpaknbph4IW+0KQ 3s7I+lpcK4qSWIz2lMIuykY7EC43FxBcG8102rNeFNhpwZpFtMCmzeV+Yr1sHQ+1DK njHFjhBM+RdXgDFyLLMI3yxSJh9CuzvMgXe/knAhbL8y5VkC3qs3QrdnIMoBfYlXrk GvqQaPiV+bvRlDtr24rMRpgNRG+m2SLGfQ6qqXcmE66ZEJbytaVZfRyTBq1i8f49UO LOzUAAJ8hq67Aq9VWBz76XPqeW0J455UUWK/nEGX1k9BXsuW3WBCtEpudwvG8oLpT0 RL2YotPPy1YOg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E2A6118006F for ; Sun, 25 Aug 2024 20:59:41 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh7-smtp.messagingengine.com (fhigh7-smtp.messagingengine.com [103.168.172.158]) (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, 25 Aug 2024 20:59:41 +0000 (UTC) Received: from phl-compute-03.internal (phl-compute-03.nyi.internal [10.202.2.43]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 9C95B114C014 for ; Sun, 25 Aug 2024 16:57:48 -0400 (EDT) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-03.internal (MEProxy); Sun, 25 Aug 2024 16:57:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm1; t=1724619468; x=1724705868; bh=llGefgcBLtu/CY9bjSE18 kRh7OL/MxE9iZfPbWpzJr0=; b=skPcMUr/mUSwEFXljrtqqDrP1plzcN9tGf2JW GwNuclclCc/USV5M+jD6z2sK9L3sY2hDrIn4YeygRse1ElqyMgrKx+GhSgR//yCf JxyE7th+SxoFOGu8ZlthZighp+Vhzc5Dhj0j/tjLzsfLz7zsuZvyzUCq96AhSvXM REFV2rxzqBzFhY+Sjsn7Jbxz+MmOp/2cPuBP79/WZMKlabDhWVOIYrbZjwXkGziO G72dNd2wVJRXajvhlBXxPlorFLOvgyPhjBEE/vfRTUgY+GCiMwyyWb5uBgYSA2jj 4dbdjVQmx9gLe6koJh/891xgGGB7SFYPRAYH9I2iPo/4YvV/w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1724619468; x= 1724705868; bh=llGefgcBLtu/CY9bjSE18kRh7OL/MxE9iZfPbWpzJr0=; b=S 3Vts0inWUaKG9Oee0O1ePY6KbE57HqVJaFKird6rOQBoy71N2EZ99no7GcF5e2sF mlb/8odw6iG6odso0kCw7jPUYRxCrCTd4KrfnqyNR1i5EKzd8epVTPg8dVdamkgF ZfWNHxWFXjvU9+jVNbZEg0Tp7GyVBXTmCBsOBa/onMmXsswfqiZsgdEo3yxaIkwg WYa32TKwywSN+DEOp87bBLySsccdehTuccvLSlF7Vdywgpu3+NV3olydZ+Boo32H 9wqtuYa1j4tN0tNBHrUP/NXHPvKsXOeUOC40ChU50Qvook8Ie6H5yfgAe8X7AhyU 5KNDc1GDDSR/UNWfEFP9w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddviedgudehgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefoggffhffvkfgjfhfutgfgsehtjeertdertddt necuhfhrohhmpedfnfgrrhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfh hivghlughtvggthhdrtghomheqnecuggftrfgrthhtvghrnhepheffgfejteekffeffeev udeuhfeugeeufeefkefgheffvdegfeejtedtvdeuhefgnecuffhomhgrihhnpehthhgvph hhphdrfhhouhhnuggrthhiohhnnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghm pehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmpdhnsg gprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghr nhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 667E929C0064; Sun, 25 Aug 2024 16:57:48 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Sun, 25 Aug 2024 15:57:28 -0500 To: "php internals" Message-ID: <68b2f0c0-17e5-4aa4-8706-92f05aca2a95@app.fastmail.com> In-Reply-To: <1b59392a-68cb-36eb-0fef-977ac7113520@php.net> References: <1b59392a-68cb-36eb-0fef-977ac7113520@php.net> Subject: Re: [PHP-DEV] State of Generics and Collections Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Mon, Aug 19, 2024, at 12:08 PM, Derick Rethans wrote: > Hi! > > Arnaud, Larry, and I have been working on an article describing the > state of generics and collections, and related "experiments". > > You can find this article on the PHP Foundation's Blog: > https://thephp.foundation/blog/2024/08/19/state-of-generics-and-collections/ > > cheers, > Derick To offer my own answers to the questions posed: * I am against erased generics in the language, on the grounds that we already have them via docblocks and user-space tooling. Pushing the entire ecosystem to move that existing syntax into another existing syntax that doesn't really offer the user anything new is not worth the effort or disruption it would cause. Reified, enforced generics would be worth the hassle. * Even if I could be convinced of erased generics as a stop-gap, I would want to see a official, supported, first-party support for validating them in the PHP linter command, or similar. If that is surprisingly hard (it may be), then that would preclude erased generics for me. * I am open to punting on type inference, or having only limited type inference for now (eg, leaving out union types). Primarily, doing so would be forward-compatible. Saying for now that you must type `foo(new A())` even if it's redundant doesn't preclude the language in the future allowing `foo(new A())` that figures out the generic type for you, and the explicit code would still continue to work indefinitely. So this seems like an area that is safe to allow to grow in the future. * I am also OK if there is a (small) performance hit for generic code, or for especially esoteric generic code. Eg, if `new Foo` has a 1% performance hit vs `new Foo`, and `new Foo` has a 5% performance hit, I can live with that. `new Foo` is a zany edge case anyway, so if that costs a bit more, I'm fine. It would not be fine if adding generics made `new Foo` 30% slower, or if `new Foo` was 30% slower than the non-generic version. * My sense at the moment is that in/out markers for variance would not be a blocker, so I'd prefer to include those from the start. That's caveated on them not being a blocker; mainly I want to make sure we ensure they can be done without breaking things in the future, and I suspect the difference between "make sure we can do it" and "just do it" is small. (I could be wrong on that, of course.) * I feel the same about `class Foo` (Foo is generic over A, but A must implement the Something interface): We should make sure it's doable, and I suspect verifying that is the same as just doing it, so let's just do it. But if we can verify but it will be a lot more work to do, then we could postpone that. * I could deal with the custom collection syntax, but I'd much rather have real reified generics and then build on top of that. That would be better for everyone. I'm willing to wait for it. (That gives me more time to design collections anyway. :-) ) --Larry Garfield