Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129135 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 9A4191A00BC for ; Fri, 7 Nov 2025 18:55:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1762541706; bh=Bmv0Duh2nHJfVzvsGHtAFwbtula5t5eyfJ+0ldN7Meg=; h=Date:From:To:In-Reply-To:References:Subject:From; b=ax/a0LHEPqXpN9STGT2uHdpeR1rvusYY9Y+s5i4dC5ZI8pub3aOCTMbjoJKzhqqG2 EibMjLfZnMzvqm3Iebyt6I9L8h3cpL47jn7JHHNPIAzzdyMtCm1CPWn3pkn9LDZVp1 6tjHpLDRu3ZDsPPi4PkxtSaltn8tt6+u7iGGuVj8K3HqGufNJcDQJVMTQ7VPqArrSs JPAT4bVzsSIX9JZEhQYcFZWNZg5RH2r6cDq/jBW19I8yCzM5RTo2XBTwHEj8IIqvg0 9F6hidJRQ47eydvaaCeIf5tibyXgK3O8LiDWlACw/Dv6kwx8LqIK9jSj011jd1DF9/ kllSqJ3crmUXA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4DED0180084 for ; Fri, 7 Nov 2025 18:55:05 +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_NONE autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-b2-smtp.messagingengine.com (fhigh-b2-smtp.messagingengine.com [202.12.124.153]) (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 ; Fri, 7 Nov 2025 18:55:04 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id 717557A0159 for ; Fri, 7 Nov 2025 13:54:59 -0500 (EST) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-04.internal (MEProxy); Fri, 07 Nov 2025 13:54:59 -0500 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=fm3; t=1762541699; x=1762628099; bh=hTHfLf6lnNZ1vEZXWs7Bl Tj/cdEU7fOPdHZle0lyIeo=; b=GQ+EH6M/3kHI2ZvjMTQlyPalulzdWiNVI1ggh 5lDxBPr9hkIynn1Hh2kkjHsKEJ9d710YG5Gbo5zn0fWbpBXwy9v5iNHJ+1/+HXcj TGB4DIUuEZiE98s4UJcDUOkE6umFljQPZ/sofoTCFJh8HNvmkotidHtYo3lwU5mY EXD5uUg8Ro3Lvv10ZBNLb3FH5lWywCtb/W5/lPUpQFZfqg4672sjHV//rNVbORgT AlZ7ALqOQBQJpn6FTtJaK/HbiatjHo29yIs6LE4qUAQe613o/riRkEnrV0fn5rAH E5zyoNM7t4KF+gymnEq4HdLbpipfn78lKquRgvOfvMUGyy7xQ== 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=1762541699; x=1762628099; bh=h THfLf6lnNZ1vEZXWs7BlTj/cdEU7fOPdHZle0lyIeo=; b=Uv6ZSF4c2SCoUiME3 RXW8c6BaOkhunRFaIUYIkGXa6Fy3RXGEK7AQOOrBkQocE0fFfKOQ5madUNz05lTY 1I/+kVUtGHJ70bhRDzsaWsZ6uhGuNA+CgZOuKQ6MA4nN/GShNJ0fIm2Lb6E0zNuN 6+stc3HqAoCInRjnTi4fl1lr2xDLHBz6iWQDwda3vFQ5uva36nuoVn2soD2a9h2P /iK9gILFx0sFg5EEZ/XelpxiQye/2bKxwaN+vsAixA4NcSh5A603uSHlRlXakes4 NSJxyQjwNPxavul1GGiA0lETEDlWyjJizW4GF4CWWWpyf3jfjZNkQG9kcmFFd5rF AqJsg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduledtgeegucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvffkjghfufgtgfesthejredtredttdenucfhrhhomhepfdfnrghrrhih ucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqe enucggtffrrghtthgvrhhnpedugedvlefgueegheefjeetffduveeltefhfeegjeffffel gedttdevkeegkedugfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomhdpnhgspghrtghp thhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsh eslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id E1B2D70006B; Fri, 7 Nov 2025 13:54:58 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: AW0xd6Hg98_- Date: Fri, 07 Nov 2025 12:54:37 -0600 To: "php internals" Message-ID: <611bb7bf-6cb1-4fa7-bab0-9d3bdc355989@app.fastmail.com> In-Reply-To: References: <83BA9524-6095-4C8B-8F82-B2F344C4D062@zort.net> Subject: Re: [PHP-DEV] Pre-RFC proposal: opt-in implicit interfaces / structural typing Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Fri, Nov 7, 2025, at 12:23 PM, Spencer Malone wrote: > The extension idea is interesting! I hadn't thought of that. > Autoloading might be a PITA with that, I'm trying to think of how you > would manage that? > > On the subject of "mistaken typing" or implicit interfaces being met by > classes that don't actually do the desired behavior, I think you're > right it's a risk, my counterargument is typescript and golang both > have implicit interfaces in some form (well typescript calls them > structural typing), but I don't think in either language I've ever > really run into a case where that risk becomes a reality. I'm hesitant > to declare this because I'm not sure this is the best way to frame this > from a PR perspective, but in many respects this proposal is viewable > as a syntax shortcut to duck typing, which is already pretty common > across PHP. While there are definitely drawbacks to duck typing, it's > still a very useful tool IMO (and becomes very cumbersome if you need > to duck type a larger set of functions). (Please do not top post.) Languages with implicit interfaces like Go also go (no pun intended) "all in" on it. All methods on an object are defined externally, possibly not even in the same file. The whole standard lib was built on that model from the ground up. That's not the case in PHP. I've been pondering extension functions for some time, and have kicked the idea around with John before. (I would do it as functions, a la Kotlin, not as a secondary class, like Rust.) Autoloading and efficiently determining that you need to call an extension are the key stumbling blocks (though my stance on autoloading at this point is "we've got opcache enabled 100% of the time, we have things like FrankenPHP, just front-load the file and move on with your life). I could see implicit interfaces working in conjunction with extension functions, if we can figure those out. I'm not sure if they offer much value without them, given the state of PHP. It would basically mean you have to opt-out of a type rather than opt-in, as now. That could get... weird. --Larry Garfield