Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125060 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 723651A00BD for ; Tue, 20 Aug 2024 01:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724117597; bh=4k+di90PLO6aMgU7cWyar3t/KEGrdO1dS9bO/wtZ9OQ=; h=Date:From:To:In-Reply-To:References:Subject:From; b=dJ1jsCMtTijumVMAHVGZFgQLlevXaAxzG27CS6nlMzHK2IKP9XrCoODFwOw4NL/Qh ByQlnv0VvZVE6bsT8kqqA0WpvM0gya6w2+fpPL52e0mA1RB9uorNQeOpZ8tWvJcb+Q 0yQGq9tDk5G/tj6VmP8B4LJHrwnJ1tFxZMzrg+vGbWuTmYAF6GaYMf2ebqflCZr94m wteQHKMj77v1thTVcw6sHNAnphdoHpNeAk/bfJZUsT1Ul6fAYkvY38YvTbd8TX6pU1 y0C2MkldzDZgnfFnA962Af/3tcqVIshHA6YZ1FZiWBDQNBWgsFy4VHsTvYUD4ev49s J/hg911xON9+w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5A314180034 for ; Tue, 20 Aug 2024 01:33:16 +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 fhigh8-smtp.messagingengine.com (fhigh8-smtp.messagingengine.com [103.168.172.159]) (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 ; Tue, 20 Aug 2024 01:33:15 +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 6EB801151B19 for ; Mon, 19 Aug 2024 21:31:26 -0400 (EDT) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-03.internal (MEProxy); Mon, 19 Aug 2024 21:31:26 -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=1724117486; x=1724203886; bh=BPgANcEECHcxr/hFBN2UZ 4smVt2/cKJYNysbMDMKQx0=; b=BsAB4OE+gr20DLE0iyMG0kyKGRqoFNSNsQ259 7XOIDJEM3LBWNdbjbHfAjEuAC6UU7AmRc2F/OirAVXueqt9/cURO4qevoeOLbUsb UA5K9jnpNabkvNhxvzDxuKUNcqr2XZUFesKKAMZT7YeoSxYje6ph3TbkyX7JJJ2l l1+yzMrs24wN7r4+mmWdKD6QV6LBvSrwR0v40LMMcMQV+WHH0hGbAr+0vKf4mAPU E48LpbY8egv7jgq4RbV4/bj9xGc3qTh5RvFkOS45J1SBkoiblCd1bcoL7xjENWWu ABMbY674dxt15qCJBGjroiSO1yoeP93hQ8QGs/1xgusV5KyIg== 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=1724117486; x= 1724203886; bh=BPgANcEECHcxr/hFBN2UZ4smVt2/cKJYNysbMDMKQx0=; b=g ifBKumNTfU5O+GlbPn5pLLSKmfrN2UXGT9I3BEhKWQMtcTA6PG1pd1Et6HPd7+3E 5rq7yEiPR4CIUqoDKO9AdTHQ+kyQuJzeoyS5Ca63+TbyI7ozZHpTdKGNShDu/f2K 0sDcHQwLFyjViKqFizxWxr0oEgokT97wTPp4PutpWk9P8Ew9MT4z6RkAdZuAPOlZ rxM5oOmtKcSn+fFMNHtEXQk/E+RaBGFMDdEVEwDaZV9iHwomqCkwk45pquns23fl yLHZxzo1nJ3gmdhLPL5JeN8kjQlFQIuJYf+ETBgtJFQjYX1LhSvkUe7z/DEmNIxs vDfwwPJ+PTHdg/3RwgvSA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudduhedggeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepofggfffhvffkjghfufgtgfesthhqredtredtjeen ucfhrhhomhepfdfnrghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfih gvlhguthgvtghhrdgtohhmqeenucggtffrrghtthgvrhhnpeffieeivdfhvdeguddttdeg teeiueegvefhteehfeeffeetudeitdehtdegjeeuieenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggt hhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpth htohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 15073940060; Mon, 19 Aug 2024 21:31:26 -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: Mon, 19 Aug 2024 20:31:05 -0500 To: "php internals" Message-ID: In-Reply-To: References: <1b59392a-68cb-36eb-0fef-977ac7113520@php.net> Subject: Re: [PHP-DEV] State of Generics and Collections Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Mon, Aug 19, 2024, at 5:16 PM, Bob Weinand wrote: > Regarding the Collections PR, I personally really don't like it: > > =E2=80=A2 It implements something which would be trivial if we had re= ified=20 > generics. If this ever gets merged, and generics happen later, it woul= d=20 > be probably outdated and quirkiness the language has to carry around. > =E2=80=A2 It's not powerful. But rather a quite limited implementatio= n. No=20 > overrides of the built-in methods possible. No custom operations ("I=20 > want a dict where a specific property on the key is the actual unique=20 > key", "I want a custom callback be executed for each modification").=20 > It's okay as a PoC, but far from a complete enough implementation. I think we weren't that clear on that section, then. The intent is that= dedicated collection classes are, well, classes. They can contain addi= tional methods, and probably can override the parent methods; though the= latter may have some trickiness if trying to access the internal data s= tructure, which may or may not look array-ish. (That's why it's just a = PoC and we're asking for feedback if it's worth trying to investigate fu= rther.) > =E2=80=A2 It's a very specialized structure/syntax, not extensible fo= r=20 > userland at all. Some functionality like generic traits, where you'd=20 > actually monomorphize the contained methods would be much more=20 > flexible. E.g. class Articles { use Sequence
; }. Much less=20 > specialized syntax, much more extensible. And generic traits would be=20 > doable, regardless of the rest of the generics investigation. > In fact, generic traits (essentially statically replacing the generic=20 > arguments at link-time) would be an useful feature which would remain=20 > useful even if we had fully reified generics. > I recognize that some functionality will need support of internal=20 > zend_object_handlers. But that's not a blocker, we might provide some=20 > default internal traits with PHP, enabling the internal class handlers. > So to summarize, I would not continue on that path, but really invest=20 > into monomorphizable generic traits instead. Interesting. I have no idea why Arnaud has mainly been investigating re= ified generics rather than monomorphized, but a monomorphized trait has = potential, I suppose. That naturally leads to the question of whether m= onomorphized interfaces would be possible, and I have no idea there. (I= still hold out hope that Levi will take another swing at interface-defa= ult-methods.) Though this still wouldn't be a path to full generics, as you couldn't d= eclare the inner type of an object at creation time, only code time. St= ill, it sounds like an area worth considering. --Larry Garfield