Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113224 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 80743 invoked from network); 23 Feb 2021 15:37:24 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Feb 2021 15:37:24 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AC37C1804E1 for ; Tue, 23 Feb 2021 07:25:55 -0800 (PST) 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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 23 Feb 2021 07:25:55 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 53C515C0132 for ; Tue, 23 Feb 2021 10:25:55 -0500 (EST) Received: from imap8 ([10.202.2.58]) by compute4.internal (MEProxy); Tue, 23 Feb 2021 10:25:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=bDaKI0 WtZHLJHRxnQEi1axHKsFHlvvRs4RIOnlr3B+w=; b=uDWC/GvfG0oe2U/+Y5zZyj i09cMpIoJaLp3mZe9IqVJBkRYCtIchjpIgAKO3otAqoTctiT2qWtbbwZtODX+i2w 6e/Gkst0bxmyFMo1JRkRi1zajD1lnI36umhp5GTE6uS5dCw3hJGmyOvcIFOwi9D2 waHKQWgjWziYDaHe0fgVo8XLuBkHA4pm7+bYviF5PoYqcZSrA7G17pavKaKT/J3v AitIYVSTqr7SEB0C9OQX3/eBP20epTfZNtEGLlgVZSq8dqfjVN7Wus3dNE39e18R w2F2f8zQC54SwXEdpi9YhzNvd1LD8YjyBj1NsQq+E341erQ1DuHCP4s6rRywMKBQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrkeehgdejhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgrrhhr hicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh eqnecuggftrfgrthhtvghrnhepfeetveffteetueeukeegjeffudeuhedthfevfeehiefh heegheffhedthefgleejnecuffhomhgrihhnpehphhhprdhnvghtpdhgihhthhhusgdrtg homhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehl rghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id F2C2D3A00B5; Tue, 23 Feb 2021 10:25:54 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-141-gf094924a34-fm-20210210.001-gf094924a Mime-Version: 1.0 Message-ID: In-Reply-To: References: Date: Tue, 23 Feb 2021 09:25:11 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] Avoiding enum reserved keyword From: larry@garfieldtech.com ("Larry Garfield") On Tue, Feb 23, 2021, at 5:21 AM, Nikita Popov wrote: > Hi internals, > > I'm a bit concerned about the addition of the "enum" reserved keyword as > part of https://wiki.php.net/rfc/enumerations. The problem is that there > are quite a few existing enum libraries (such as > https://github.com/myclabs/php-enum) that define an Enum class. While the > implementation of enums in PHP 8 obsoletes these libraries, it still > constitutes a migration problem, especially for libraries supporting more > than one PHP version. > > I don't believe that the keyword is strictly necessary: We can recognize > enum declarations as T_STRING T_STRING, where the former is checked to be > equal to "enum" by the parser. It so happens that this is syntactically > unambiguous at this time. We may be forced to introduce the keyword at a > later time, if it becomes ambiguous. > > Another possibility would be to recognize T_ENUM in the lexer, but only if > it is followed by whitespace and an identifier. This would possibly be > friendlier for tooling using token_get_all(). It would not permit comments > in between the tokens though. > > Thoughts? > > Regards, > Nikita If I understand correctly, neither of these proposals would change the user-facing syntax, right? Just the parser details? I'm fine with that as a transition plan. I think long-term it's better to have all keywords behave the same, but if we could use one of these alternates for now and then switch to a normal T_ENUM in 9.0 (thus not breaking a class named Enum until then) I'd be fine with that. I can't see a comment between "enum" and "Suit" being useful, so that's an acceptable tradeoff for me. --Larry Garfield