Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118059 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 47354 invoked from network); 22 Jun 2022 15:50:14 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Jun 2022 15:50:14 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4ED4B1804D0 for ; Wed, 22 Jun 2022 10:39:47 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS197540 193.30.120.0/22 X-Spam-Virus: No X-Envelope-From: Received: from stefan-marr.de (stefan-marr.de [193.30.121.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 22 Jun 2022 10:39:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=stefan-marr.de; s=20191205; h=To:References:Message-Id: Content-Transfer-Encoding:Cc:Date:In-Reply-To:From:Subject:Mime-Version: Content-Type:Sender:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Eac0qoz0eF4sdRmHPzEJop5mF4BPIKuSmNtuWxJ1UkM=; b=AN3KqzeO02eo6HlqLyssYljJv E+szZZtwp7esN+4zn23nAr+KuhUs10HnzbajnDh+NrGSPtzphgpkELB8PdCG1+GoeBYCe9/sqIG/i t4q7qhCc2ZMs9V40TmjXeI1cVZZKF2kqUOXmhXznNEODKtyjLHU5EAwY9nBea379qNTwc=; Received: from [90.255.217.11] (helo=artemis.broadband) by stefan-marr.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o44KM-0005NX-Ey; Wed, 22 Jun 2022 19:39:42 +0200 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Reply-To: Stefan Marr In-Reply-To: Date: Wed, 22 Jun 2022 18:39:35 +0100 Cc: shinji igarashi , php internals Content-Transfer-Encoding: quoted-printable Message-ID: <47080817-4B05-49C9-ABC1-B1EFF55905A7@stefan-marr.de> References: <029d3b2e-e8d3-41d0-acc9-7f7514651030@www.fastmail.com> To: Nicolas Grekas X-Mailer: Apple Mail (2.3608.120.23.2.7) Subject: Re: [PHP-DEV] [RFC] [Under Discussion] Constants in traits From: internals@lists.php.net ("Stefan Marr via internals") Hi Nicolas: > On 22 Jun 2022, at 17:31, Nicolas Grekas = wrote: >=20 > > I'd like to start a discussion on an RFC to allow defining constants = in traits. > > https://wiki.php.net/rfc/constants_in_traits > > > > I'm looking forward to your feedback, including corrections on = English wordings. > > > > Thanks! > > > > -- > > Shinji Igarashi >=20 > I am initially lukewarm. One thing not addressed in the RFC that = should be: Why were constants left out of traits previously Hm. This isn=E2=80=99t something that I remember coming up specifically = back then. If it had been discussed in more detail, I=E2=80=99d probably have = included it in the RFC. So, my working assumption is: it wasn=E2=80=99t something I really = thought about. > and what has changed to make them make sense to include now? (I don't = recall, honestly, so I have no strong feelings one way or the other = yet.) I am not sure there are reasons to specifically exclude them though. The RFC, reading over it briefly, and having been away for very long = from the topic, seems sensible to me. Taking a very restrictive approach, seems sensible to me, too. > I'm also wondering why the default value of a const (and a property) = could not be changed by the class importing the trait? This sometimes = hits me and the original RFC doesn't explain why this is needed. For constants, I=E2=80=99d lean towards not allowing changes. If you need to parameterize the trait with a value, having an abstract = method return it seems a much clearer way of doing it. Then all parts of the system know =E2=80=9Cit=E2=80=99s not a = constant=E2=80=9D and I need to cater for different values. The reason for the strict policies on property conflicts was to keep it = simple. Be conservative, and avoid silent bugs. Please take everything I say with an extra pinch of salt. It has been a long time. Best regards Stefan --=20 Stefan Marr School of Computing, University of Kent https://stefan-marr.de/research/