Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115616 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 91333 invoked from network); 1 Aug 2021 11:14:19 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Aug 2021 11:14:19 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 875011804B0 for ; Sun, 1 Aug 2021 04:42:32 -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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS13238 5.45.192.0/18 X-Spam-Virus: No X-Envelope-From: Received: from forward105j.mail.yandex.net (forward105j.mail.yandex.net [5.45.198.248]) (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 ; Sun, 1 Aug 2021 04:42:31 -0700 (PDT) Received: from myt5-8d25db0e1b73.qloud-c.yandex.net (myt5-8d25db0e1b73.qloud-c.yandex.net [IPv6:2a02:6b8:c12:12b:0:640:8d25:db0e]) by forward105j.mail.yandex.net (Yandex) with ESMTP id 0E9EFB21EF5 for ; Sun, 1 Aug 2021 14:42:29 +0300 (MSK) Received: from myt6-9bdf92ffd111.qloud-c.yandex.net (myt6-9bdf92ffd111.qloud-c.yandex.net [2a02:6b8:c12:468a:0:640:9bdf:92ff]) by myt5-8d25db0e1b73.qloud-c.yandex.net (mxback/Yandex) with ESMTP id ENp45BC5Qw-gSHuhwQv; Sun, 01 Aug 2021 14:42:28 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=php.watch; s=mail; t=1627818148; bh=3gZnj16kSi6pJ9+bPRCz0TvutE0gZBDqqc4WpRBNVdA=; h=To:Subject:From:Date:References:Cc:Message-ID:In-Reply-To; b=CT0O255nIahFLJQ1KVAzEZuiA1dkXz1YQPGUF8uOaXnHglNXGdVhzuOhAxocC5f9T xVgItypGz5E5ABdPGE0YuSM4S9W2CF3OvZ74uhm0YO0h6Is258VHC9jp2WxWKNBZuh QdmZWDTpQnQ1wuLKZ/xT3tOWRwmmrxffiGWhRPA0= Authentication-Results: myt5-8d25db0e1b73.qloud-c.yandex.net; dkim=pass header.i=@php.watch Received: by myt6-9bdf92ffd111.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id m0NKbF2lWm-gRjGcTLF; Sun, 01 Aug 2021 14:42:27 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Received: by mail-oi1-f171.google.com with SMTP id o185so20617563oih.13 for ; Sun, 01 Aug 2021 04:42:27 -0700 (PDT) X-Gm-Message-State: AOAM533zTU4Cu3cj0nnWeleZqXzBVdjtYks9GBDPiNMsK6uPiXiPkYn5 JRiYcrLq4ulbWia4Ui3gy+PQfCm1ceTtz8nHhg4= X-Google-Smtp-Source: ABdhPJyCmvKs1dghxp+GrE5RJmYEbHt45WLCLL7Tmf3WfSFp8yv8sxwiIv1sei0MzUBKOz5ZRi1n/bsyHfSMMcNPHKY= X-Received: by 2002:aca:1b03:: with SMTP id b3mr7102200oib.18.1627818146789; Sun, 01 Aug 2021 04:42:26 -0700 (PDT) MIME-Version: 1.0 References: <22EF92EC-C5A3-498E-9EFD-DE2B5B204BB7@gmail.com> In-Reply-To: <22EF92EC-C5A3-498E-9EFD-DE2B5B204BB7@gmail.com> Date: Sun, 1 Aug 2021 17:11:59 +0530 X-Gmail-Original-Message-ID: Message-ID: To: Serhii Smirnov Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] RFC: autoconst From: ayesh@php.watch (Ayesh Karunaratne) > > Hello! > > This is my first RFC proposal. I have an idea about introducing autoconst keyword. > Motivation: > reduce duplicated code (copy/pasting constant name as value) > reducing potential typo errors in constant values > > instead of defining constants like: > const FOO = 'FOO'; > > they could be defined like: > autoconst FOO; // defines a constant FOO with the value 'FOO' > > Also, modifiers could be useful: > autoconst uppercase foo; // defines a constant foo with value 'FOO' > autoconst lowercase FOO; // defines a constant FOO with value 'foo'; > > and maybe: > autoconst camelcase FOO_BAR; // defines a constant FOO_BAR with value 'fooBar' > autoconst snakecase fooBar; // defines a constant fooBar with value 'foo_bar' > > could be listed like: > autoconst FOO, BAR, BAZ; > autoconst lowercase FOO, BAR, BAZ; > > What do you think about that? If you like my idea, I would request a karma for creating this RFC in the wiki. Hope you'll like the idea! Hi Serhii, With Enums supported in PHP 8.1, I think this pattern of using constant names with identical values will see fewer use cases. I also don't think that a proposal to add new common keywords like `uppercase` / `snakecase`, or adding any magic to constant names (because PHP 7 supported case-insensitive constants) will be received well either. Thanks, Ayesh.