Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118209 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 8626 invoked from network); 6 Jul 2022 12:52:47 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Jul 2022 12:52:47 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5F9FC1804F8 for ; Wed, 6 Jul 2022 07:45:49 -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=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (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, 6 Jul 2022 07:45:48 -0700 (PDT) Received: by mail-ej1-f52.google.com with SMTP id o25so27531292ejm.3 for ; Wed, 06 Jul 2022 07:45:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=NF7v9uO+KxHAR1gx/IUhF0IVmwHpym59mQG4mX0fOE4=; b=abiDsNKHN67gbkbknfVwy7Zk8aiM3t1v8zuzKf9qcus3f6pPzGVClU5s9okhk0tQFJ HH1pXN9OHzBTKlbqcP/tC8/jKLq37U2woxY7VuuaPQ8mg8BI0j+T6o9GjNArqWBPsVDV w9eTJXxJqvD5bYPiMHPNjsnWQeb5xJ0tlhQIKqwpdbqfBHQ2RbW0cTK31qV451Nugnci ZeMbY2DO+DDNejLI9c4ftSq5d1jncAeIhTuJwkLKP2FLP7ygVosW3swstoT+DOm/bl0G +7Zey1OqGVvaYFo9dCPiFM47n3UMJSLUAY8YINCUJrQTTwUw0ktO23zSFGuKgZ3eYlUL nnKg== X-Gm-Message-State: AJIora8OLOQPOsCoJveVdI5NlgIXVIrymMTH14ut9xnt0I6Qft3gPd0D QSFLEteHG0533/rQXfJfh3B5RwKGWuriwA== X-Google-Smtp-Source: AGRyM1tlpIAaKsZBIKyB8UXXRrsVedlk9MyqBOnHqhR5B9XDYCzQflSmjwix/FIluDu2+XE6CNv7eQ== X-Received: by 2002:a17:906:a3ca:b0:726:2bd2:87bc with SMTP id ca10-20020a170906a3ca00b007262bd287bcmr39598064ejb.226.1657118747442; Wed, 06 Jul 2022 07:45:47 -0700 (PDT) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com. [209.85.221.52]) by smtp.gmail.com with ESMTPSA id x2-20020a05640225c200b00435651c4a01sm26213702edb.56.2022.07.06.07.45.46 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Jul 2022 07:45:46 -0700 (PDT) Received: by mail-wr1-f52.google.com with SMTP id bk26so7331993wrb.11 for ; Wed, 06 Jul 2022 07:45:46 -0700 (PDT) X-Received: by 2002:adf:f78b:0:b0:21d:6fef:f4e1 with SMTP id q11-20020adff78b000000b0021d6feff4e1mr10317261wrp.92.1657118746116; Wed, 06 Jul 2022 07:45:46 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 6 Jul 2022 23:45:34 +0900 X-Gmail-Original-Message-ID: Message-ID: To: Marco Pivetta Cc: internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] [VOTE] Constants in traits From: sji@sj-i.dev (shinji igarashi) Hey Marco, thanks for giving your reasons! > traits are pretty much unnecessary in the language. Perhaps for this RFC it is necessary to first provide use cases for traits = and defend themselves before trait constants. It's understandable that this is a premise that needs to be shared first, since trait was originally a mechanism designed to replace certain uses of inheritance, and inheritance itself is an enough controversial feature in today's PHP world. This discussion on "how traits should be treated today" is probably an important point for the community, but I will reply to this in a separate e= mail, so I will first consider the other points in this email. > invariants shared by trait (example in the RFC) are generally to be > separated to clear invariant objects/functions/static methods, instead of > being put in a trait I did not understand the intent here. I think both traits and classes are examples of mechanisms to package behavior and data. Why is it allowed for classes to represent invariants by const, but not for traits? > a trait does not know the public API of its implementor either, so > self::SOME_CONSTANT inside a trait points nowhere sensible, since > there is no clear contract on the possible implementations. Since the proposed trait constants cannot be overridden in the composing class, their definition serves as a sort of contract for the internal implementation of the trait. > Referencing symbols of the implementing class in a trait is a clear > mistake (again, an example from the RFC) I agree with this point. And avoiding this is one of the main goals of this RFC. > this expands trait compatibility checks, introducing a number of > potential error scenarios I am skeptical of the claim that this is a problem that the introduction of trait constants itself has. If there is a situation where this is really a problem, it would be another problem where members of traits have no choice but to share namespaces with= in the composing class, so I think it would be better to solve this with anoth= er proposal. Whether we should solve the name conflict problem with another proposal wil= l ultimately come down to the question of how we should deal with traits in t= he future, though. Thanks! -- Shinji Igarashi 2022=E5=B9=B47=E6=9C=886=E6=97=A5(=E6=B0=B4) 18:46 Marco Pivetta : > > Hey Shinji, > > On Tue, 5 Jul 2022 at 23:39, shinji igarashi wrote: >> >> Hello internals, >> >> I've started the vote for the Constants in Traits RFC: >> https://wiki.php.net/rfc/constants_in_traits >> >> The vote will end on 19. July 2022. > > > I voted "NO" on this. > > Reasoning: > > * traits are pretty much unnecessary in the language. Since their introd= uction in PHP 5.4 their usage went from "let's try this out" to "how do I b= urn this with fire?". I don't want traits to expand in scope: they already = do enough damage with their built-in accidental complexity. > * invariants shared by trait (example in the RFC) are generally to be se= parated to clear invariant objects/functions/static methods, instead of bei= ng put in a trait > * a trait does not know the public API of its implementor either, so `se= lf::SOME_CONSTANT` inside a trait points nowhere sensible, since there is n= o clear contract on the possible implementations. Referencing symbols of th= e implementing class in a trait is a clear mistake (again, an example from = the RFC) > * this expands trait compatibility checks, introducing a number of poten= tial error scenarios that are unnecessary (due to the already mind-boggling= over-complicated `use TRAIT1, TRAIT2, TRAIT3` semantics) > > In practice, while this may make on surface because you can declare const= ants everywhere, declaring more stuff on traits is problematic. > > From a technical and detail PoV, your RFC is well written and implemented= : it just solves a problem that doesn't/shouldn't need solving. > > Greets, > > Marco Pivetta > > https://twitter.com/Ocramius > > https://ocramius.github.io/ >