Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130826 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 lists.php.net (Postfix) with ESMTPS id BB6631A00BC for ; Mon, 11 May 2026 12:10:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1778501461; bh=I+RZm+DoPqZTw1xs0QELMElsegv4ubEk+klLz5OxDx4=; h=Date:From:To:Subject:In-Reply-To:References:From; b=RM2hoIqI9/rmRWJcUnnGYPWW7aDRMNzvW7vwlg4yGt7hgrbi3UisybjxkEqEM9CQz llTDyGn5QcfGAZDDy2CfgfykCj2yZ9sfBY5vmeUUNVvk7u7hi0MN0YZYDhseBKlKsI OTqOiaQ9FZjgju4msmBxKfet99Ir1UdhWW3tqjV1MnZAFfBHERjz9qtbXREafianMd 6jGhTFILpgSfjWs6+l4YTHpnA/1GvfyQ03PtY4VY2HkEQmfJJTgH/n7v9HCGJXVkxp Z+UAQ7MfrmpL2DqWbhtC6nMyUG3Ing/NeBLz61gwDjpZyM28dbcBzbGkoIrafQ8mYp 5nFLymZbjZQCA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EB95A180040 for ; Mon, 11 May 2026 12:10:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) 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_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-b6-smtp.messagingengine.com (fhigh-b6-smtp.messagingengine.com [202.12.124.157]) (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, 11 May 2026 12:10:59 +0000 (UTC) Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id E35AE7A00FA for ; Mon, 11 May 2026 08:10:53 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Mon, 11 May 2026 08:10:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; 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=fm3; t=1778501453; x=1778587853; bh=I+RZm+DoPqZTw1xs0QELMElsegv4ubEk+klLz5OxDx4=; b= C2BtZDXVYHJwytRcUr1T8HVo8VTXEpU/LYybR2SBWUK8StvzQ80/xGDq/xMRDKpT Uc5Kvd07J085rxeO6m/T37j011Pn9vXd1yyZPmn3SEd0zbQEIYThJY9p/JhZJW/9 VAVqkzibJFooKJ1dkygLQrNOoIFmBMo9pjQI4YmuMmDU+8ol5vZBDGVdQabaLiO2 aRdaC22+IXDyuTe3ktrZ9Z988EvBIY4vyFB3ISk7Jdwpfa66AlOkEqPlXjZjQUJK hxxrf0Xzoy9ku4oRrwHGyWtgFC+BVRdsjykLNOn1N+jzZpVufOyUoTuUeS5IAsb5 wVEaiXQjGstWujTZck1f6w== 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-sender :x-me-sender:x-sasl-enc; s=fm3; t=1778501453; x=1778587853; bh=I +RZm+DoPqZTw1xs0QELMElsegv4ubEk+klLz5OxDx4=; b=E8k0v3YlEaZCJuZah 8n2h4VYyoYt7nQ7Z+0DMRWtOCjz/Wxhs3vIOvf6X3TsYeFocvM1olHZ8vwNB+2Sy WSgg34qNkY4qxebwID27PmjDVMEMEWA6ZppJh/j0a/N3XrTmt1NKeau4Fw0lmOv0 eZdoR5us3HXxmIyRN8B2PvnyvVCEIxayTzLff/BHx00xQZ9EQoSWC02iFij+wZMh mrspwHW42k/Edi3xgbuhzZrXvEprxJlSPJXmzibhZgPyksgDNN6lBF/XFXmMEsmo zPyEdg760v/li5igT7yWfKTYOgYg6ZItm64RVrzpCSVzRYhYfKAdbAANhRbSHAXM ZN7Tg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdduudekkeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpeffhffvufgfjghfkfggtgfgsehtqhhmtd dtreejnecuhfhrohhmpedftfhofigrnhcuvfhomhhmihhnshculgfkoffuohfrngdfuceo ihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqeenucggtffrrghtthgvrhhnpeehle ffteeigfevudetfedugedtudevledugeeugeelheeihfehgfdtkeevvefgleenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehimhhsohhprdhphh hpsehrfigvtgdrtghordhukhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphho uhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Mon, 11 May 2026 08:10:52 -0400 (EDT) Date: Mon, 11 May 2026 13:10:49 +0100 To: internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] [Discussion] Bound-Erased Generic Types User-Agent: K-9 Mail for Android In-Reply-To: References: Message-ID: <8E4D29B2-A8FC-4CEC-8B74-C939521A102F@rwec.co.uk> Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 10 May 2026 20:02:32 BST, Seifeddine Gmati = wrote: >Hello Internals, > >I'd like to start the discussion on a new RFC adding bound-erased >generics types to PHP=2E Hi Seifeddine, Thanks for putting together this proposal=2E However, I am generally against any *unenforced* implementation of generic= s=2E I choose that word carefully: it is not type erasure per se that I am = against, but the ability to write code which *looks like* it enforces parti= cular signatures, but actually does not=2E There is lots of background in the RFC, but one relevant comparison not re= ferenced is Python, where all type hints are unenforced=2E Static analysis = has to be run manually, so code can be written, and even published as a lib= rary, with completely incorrect type information=2E Users of that code then= make reasonable assumptions based on the published types, and get unexpect= ed run-time behaviour=2E Note that this is fundamentally different from the experience of languages= like Java or TypeScript, where type information may be erased, but is stil= l *enforced*, because static analysis is a compulsory part of the compilati= on process=2E Having most types enforced is obviously better than none, but as far as I = can see the same risk exists - someone can write code that claims to use ge= nerics, and publish it to Packagist without actually checking it; or write = supposed invariants which only hold if the user also analyses their own cod= e=2E This is true today, of course, but the claims are much weaker, sitting= in docblocks not native syntax=2E Once we go down this route, it will be very hard to change our minds, beca= use enforcing types in code which previously ignored them would be a breaki= ng change=2E I think the only options I would personally support are: a) run-time enforced generics in limited positions (as in the blog post yo= u link to from Gina and Larry) b) generics which are erased at compile-time *by a tool that also enforces= them* (as in Java, TypeScript, etc) Regards, Rowan Tommins [IMSoP]