Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125071 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 96AC71A00BD for ; Tue, 20 Aug 2024 14:03:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724162740; bh=/+J0TSV2MveGmuRFGrjeeX7IFhyEwik+lfwU8zfUJWE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=aSoFjav0vWVVfS3ABvAnthElu4cwO0fDUbKO5a+LnPh6WKNK9jPgrK6RbRK+qslRz 9TCtAQeMygJHhQuhV3zg0N9a1raAwScgkzrb0DAYV5nLJgOWlqIHdKRX45mFqdAoPi cIC7bxo85WYcqxUBy8E9HiTo04qLAOv9Ki/RkNDr6ztb1VQQSZk+eohFzYB/gFXB8z W4z6aTx6QBELwnuoJJ7pZFlPoedV+5MSwUqbNnggvTS2YAKVJzrG0XWomzWRPOjrwD jv4tTCRy2Ncyqyl+P/0u2SztFME/VkzrTD1q7SDqeTAy/V9e4kP8Go7M1boYsW48BD g3hunVCjblqmg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 04D17180034 for ; Tue, 20 Aug 2024 14:05:40 +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_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (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 14:05:39 +0000 (UTC) Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a7a94478a4eso1133492066b.1 for ; Tue, 20 Aug 2024 07:03:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724162629; x=1724767429; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Tl9Y5zHhcIpGQQBJfPl2HphI5tuDKXpVUNTNvc1E/k4=; b=fwDaVoHiRJTu+SlmaP92h8xSVNgWt4UkVM8DBCCSdAl93Mw4TCwWak9JPMFM5I0IfK /KOW12qcN2DXwuX6h99q7xH/Rt7qz771zS5UvpJj7O2O3krawL9iBKY+t3uEX7fq3YO9 mddQRSVsiA/oHsPqv3Bjk12a8GGrVfJvjEU42oD+hGHQ/q9Fp7q1bHh6lKrqdTXlfhet 4ttlj4bTe5sp3GN5POOIkKZzbtGxvcycyJnuy/eNVdfkD1CygP5VWcgUjKHN9gY78F6+ HkmPkSGyDNkE7j4OEsIL8VgkZp5Qix04lwx11jZjOuTayTVi1w0R3oRqnMA4WopHSjHp OURw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724162629; x=1724767429; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Tl9Y5zHhcIpGQQBJfPl2HphI5tuDKXpVUNTNvc1E/k4=; b=eX8wsEC8dMSHKBtngmB6EiAXkX67SwmANBFuMYOsCvlNlPbNVBF8g8kkPvO/BkBnDc c5DOOEmI8f6j1lPQQ8LT0yX7Kpgx47QzaKxm1BzOOlUH5G3MZBMdJsSf0P1q+MhwPj68 lqu4i0gs9bi1R3gHK6VM7O/RT3yGVcsnaLPvN7smHfp2isgAAJrMZnWQGSpD9376MF3R wtpOowbMoL7MrmyWkRAuTJnDUfCqBK0M1x8DBfRNguSM2iA+v331y/Yb0d6iED45gWV7 fYY4Iug/RZARQHf8P/h3avdoMRr1myq5JBa5l1O7ZIfOzyQy0g0JVi+DWJAnW7T5fyWO nurQ== X-Gm-Message-State: AOJu0YzSQcxpDdsfwTReVpr+ee0S9e4T5Bt/bgSHl0SKA0c9NjPshqMq jZpBfKFRE6R26FqZwx4dXLHA2fYWmP/JfgvECQU/lrIYL7jgg+QrIjecqjLk9rzlKt5jUJ96vNB jhCw9vg3+BRfeNsg+TewCz5mVY0NV0T0U X-Google-Smtp-Source: AGHT+IFeYuUC5r4rLR0xHico4zmrZG5DuQXixbQw7YFT+vg+KYYJPWQ/+M7ly8VltEaNlwL1wl6JNMT8efl5+QDUkMc= X-Received: by 2002:a17:907:2d2c:b0:a72:5f3f:27a2 with SMTP id a640c23a62f3a-a8643fd9be8mr378711266b.26.1724162628015; Tue, 20 Aug 2024 07:03:48 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <1b59392a-68cb-36eb-0fef-977ac7113520@php.net> In-Reply-To: Date: Tue, 20 Aug 2024 16:03:36 +0200 Message-ID: Subject: Re: [PHP-DEV] State of Generics and Collections To: Larry Garfield Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: arnaud.lb@gmail.com (Arnaud Le Blanc) Hi Larry, On Tue, Aug 20, 2024 at 3:32=E2=80=AFAM Larry Garfield wrote: > > In fact, generic traits (essentially statically replacing the generic > > arguments at link-time) would be an useful feature which would remain > > useful even if we had fully reified generics. > > I recognize that some functionality will need support of internal > > zend_object_handlers. But that's not a blocker, we might provide some > > default internal traits with PHP, enabling the internal class handlers. > > So to summarize, I would not continue on that path, but really invest > > into monomorphizable generic traits instead. > > Interesting. I have no idea why Arnaud has mainly been investigating rei= fied generics rather than monomorphized, but a monomorphized trait has pote= ntial, I suppose. That naturally leads to the question of whether monomorp= hized interfaces would be possible, and I have no idea there. (I still hol= d out hope that Levi will take another swing at interface-default-methods.) > > Though this still wouldn't be a path to full generics, as you couldn't de= clare the inner type of an object at creation time, only code time. Still,= it sounds like an area worth considering. Monomorphization as a solution to generic classes has a memory usage issue (it requires duplicating the class entry, methods, props, and also opcodes if method bodies can reference type parameters), and does not solve all the complexity: https://github.com/PHPGenerics/php-generics-rfc/issues/44. This would be less a problem for traits, as there is already some amount of duplication. Best Regards, Arnaud