Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110222 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 56163 invoked from network); 20 May 2020 22:17:23 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 May 2020 22:17:23 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9B17B1804E0 for ; Wed, 20 May 2020 13:56:07 -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_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS48854 94.231.96.0/20 X-Spam-Virus: No X-Envelope-From: Received: from smtp.simply.com (smtp.simply.com [94.231.106.220]) (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, 20 May 2020 13:56:06 -0700 (PDT) Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by smtp.simply.com (Simply.com) with ESMTPSA id 49S4m53cRmz62sT for ; Wed, 20 May 2020 22:56:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=givoni.dk; s=unoeuro; t=1590008165; bh=3jcGlQ9cwjvbyrbuJDpee6GiIqdeEB4NSbK3yX1Ho7c=; h=From:Date:Subject:To:From; b=axuDk4TEUOnKg0IhToAQlIme4RvCstRV6N72hall6955y6VunzHl/Pj5HSEV0fQVm jHKnOyQPb9uoWqOAZgW192pR6bBWKiFxxfuElgnuE+Y/h3bT71emGDQEcRxom7tVP8 5RqrzJq1PPFbSjH9jKB/gaXlEgQV62uO7a5G53ng= Received: by mail-wm1-f54.google.com with SMTP id w64so4274979wmg.4 for ; Wed, 20 May 2020 13:56:05 -0700 (PDT) X-Gm-Message-State: AOAM532b4UCgLKsixKQywV+yLUH/8qc8/3w4+uJO3bIMCwMHbDHxBhMM BBETXuj0ph8DbLGl18fkIJdKzxcxPXTxybONQDA= X-Google-Smtp-Source: ABdhPJw2Ey/NU+aXCgjqJQXP1ePSLjzckF8PNZw5qOi4588Q2jLSNjzxWdhS2bhF2eSvpM3tjHoFmsSHd0CHD94djuU= X-Received: by 2002:a1c:19c1:: with SMTP id 184mr5680822wmz.29.1590008165036; Wed, 20 May 2020 13:56:05 -0700 (PDT) MIME-Version: 1.0 Date: Wed, 20 May 2020 22:55:53 +0200 X-Gmail-Original-Message-ID: Message-ID: To: php internals Content-Type: text/plain; charset="UTF-8" Subject: [PHP-DEV] Reserved words and class name collisions From: jakob@givoni.dk (Jakob Givoni) Hello, It's a common thing to want to introduce a new keyword as a reserved word as part of an RFC. (Recently: match, mixed, guard, readonly...) These new keywords always lead to possible BC breaking changes because they become unusable for namespaces, class names, function names and global constants. This may sound frivolous, but has it been considered to try to find a way to make it possible to have some classes of language keywords and identical class names etc. living side by side? One thing I could think of is to allow prefixing either new keywords or conflicting class names with a special character whenever there is a possibility of ambiguity in the syntax. Let's take an example - I've always wanted to name a class "Function" :-) It would live in a namespace, f.ex. \App\Middleware\Function. I don't really see how declaring the class Function or using the fully qualified class name could be an insurmountable obstacle to distinguish from the keyword used to declare a function. However, if you're already in the \App\Middleware namespace and just find the untethered Function in the code, that would not be nice to the parser. But if we prefixed it with .\Function the confusion would evaporate, wouldn't it? This idea would not eliminate this kind of Backward Incompatible Changes but the upgrade path to simply prefix the class name etc. with .\ or something else, whenever it was found out and alone, would cause a lot less friction that renaming files and classes. And as such it just might lead to more, otherwise nice RFC's being accepted :-) If this sparks some interest, let me know. Or rather, tell me please in a mild tone why this would be a total disaster. Best regards, Jakob