Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118396 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 62508 invoked from network); 10 Aug 2022 13:14:33 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Aug 2022 13:14:33 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D2C871804AF for ; Wed, 10 Aug 2022 08:16:18 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 10 Aug 2022 08:16:18 -0700 (PDT) Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-324ec5a9e97so145758137b3.7 for ; Wed, 10 Aug 2022 08:16:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=6egwLCvpZdMbHRU918ggnKPqtBFxWpQWbplHQ1LLx5M=; b=MEpRNpWiR+RDpJAU9NofkBK1MWtMiBQB9feF5Y9nw6ysqcWz40ziWkA+IZJ66ToORR /Deyg//X/2cV9/6ON6rbJ7Qi61fKB77LtLMtt9OIx1QSY08uSTkCuRPH5S+q/j8tirIH xYaEwf1hRHPjRuJz3V1/l2wfkQDDk9JHGmnLE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=6egwLCvpZdMbHRU918ggnKPqtBFxWpQWbplHQ1LLx5M=; b=Owwfzz+Pgle1mtnP2kW2BSPf3A2UQEVYwOiCec2DRDoWVAS96StIYI0m0MvRu0WzAv L5L+5/rSU7vl3scQ0PY3yQVmwn6mCmGtnNMWJVdDBRdKcISsv2nKmNdYiuiyt/FkE6Gt zM7VWtDh5tlV4/6y5Ic+bB6bWBq2XzoHMOX9QOQSnhUry+PTluXuv7Omo1t589mMGeVu j8Sek+3prYJDxo9H2I31dB9Xq8kyLzODMsGyTS3e5FOG392vROzHAqLR0yKoXRwAsVFA zivVbwUY0DLGXuzY0A9Upd90J+GEVJPDwy8iedtYTm61NG0v41b8v3PiVnhthO3O0USh aJtQ== X-Gm-Message-State: ACgBeo3mzBOU9E1T3HECkC3J5jjPpcWNHOHe92+Bv00qGUI8zazRnrAO 1dZgNgLrmjMsrFwoYz/ym4gq6bdrP8Kc7KqNtzo7GA== X-Google-Smtp-Source: AA6agR7l4thCpyQDFduB3vwNGLyxhu/h889faxFTGjfemGmpP01mMTh5QLGawHy452GrUsSbdf82RWZORaDjUsKV62o= X-Received: by 2002:a81:b045:0:b0:329:5160:41a7 with SMTP id x5-20020a81b045000000b00329516041a7mr23575604ywk.306.1660144577609; Wed, 10 Aug 2022 08:16:17 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Reply-To: Levi Morrison Date: Wed, 10 Aug 2022 09:16:06 -0600 Message-ID: To: autaut03@gmail.com Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [Concept] Extension methods From: internals@lists.php.net ("Levi Morrison via internals") > What are your thoughts? It's a fantastic feature that I've used in Rust, although there are some differences. First, it doesn't work for regular methods -- they have to be part of a trait. Secondly, in general a trait can only be implemented for a given type if it is in the package which defines that type, or in the package which defines the trait. Third, the trait must be in scope. These rules help people understand where the methods are coming from, which is particularly helpful for large code bases or teams. PHP doesn't really have tools for these kinds of restrictions, but I think it's necessary. You'd need some way to manage where extension methods are loaded, how they are found, and without pessimizing performance of method calls in general just because this feature exists.