Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115617 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 93219 invoked from network); 1 Aug 2021 11:32:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Aug 2021 11:32:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 53ECA1804B0 for ; Sun, 1 Aug 2021 05:00:36 -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,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS 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-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 1 Aug 2021 05:00:35 -0700 (PDT) Received: by mail-ej1-f41.google.com with SMTP id hw6so12226034ejc.10 for ; Sun, 01 Aug 2021 05:00:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=e5pTcDnclZQBaxQllg5vwo42yh4N7fb1RtIA2TCdLGA=; b=T3f1GHcsR/lVPwa8XI3rKfS9LBFZeOJ604v7JVRPJtj/gosKdCjfEuESUFvfuhdwjq pEq8emdIMQLYnHYr8feWhg2bseT7TwwHVvUryDp3nP0eyK8tWhmGQ99+BsAPGQO8IuJZ dOJSHC4ULzGZybeFI1rdmS4Jv7EAk1veYlFcbNBEM3Usq8UalAOL6C0sWt38BskzZbjD uwU9HAxlxZWCOgxu+aCMZmIhPs5LTfe+YbywE1zpixhkgCN5t7x6u/VhVMAMvP8reQm2 CITz/CoAKrSRVKu3/3tsZmScnSxmB6y9EuJbe4SbG3YfoTYeiJI6w4o+GqOQSiTacDwj AqPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=e5pTcDnclZQBaxQllg5vwo42yh4N7fb1RtIA2TCdLGA=; b=GZzmmBn5WgLnXOaMhBkseZqWZHRsLoVFBEkniq4g4XidAEBrGn8279irRl0GxmWbqG Prwcpm3evbkOSvhe/ju3om5r2XH4jkATMbfCrzryMnYw6OUX3N2YmHVMGJeckhSQ3C7u JpuoX+Hd4nYtdAavTfNhY+M/b+xQy7ynmcbA/r9gG+TGnKXh/rl1cpL/Vub+HBCHp0+w wJMLMfnY51xiOqg7/Jt7aXnleToURu3qwpeOzTJKSkfJmRVwNynmk0nFTezrTk1oKeBG /xgQhocC0+wnJww4HKS0era7MwxflMpFiWdu9AwgMOUUsx1qQzBlldmonmpAuAJShK/y t0pQ== X-Gm-Message-State: AOAM533lgz8jNCt/0W4FeG/nkGDLcr1++wPmDkiLjLkCPe7JyP797JI9 BjOHEEOneXCv8gtEXijluYdLirthah3LgLtmAks= X-Google-Smtp-Source: ABdhPJyEPAJL/yTq+uVFeLAaVi/Z3VF6jY9TpPMN1e+vQ5WAGfPqSl1X7jb2aU3ZsbPvzXpbnsi8u4HwGcaJ/QJaPjM= X-Received: by 2002:a17:907:2ce7:: with SMTP id hz7mr4372484ejc.35.1627819231853; Sun, 01 Aug 2021 05:00:31 -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 15:00:19 +0300 Message-ID: To: Serhii Smirnov Cc: Internals Content-Type: multipart/alternative; boundary="00000000000012c42305c87e33b4" Subject: Re: [PHP-DEV] RFC: autoconst From: maxsem.wiki@gmail.com (Max Semenik) --00000000000012c42305c87e33b4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable =D0=B2=D1=81, 1 =D0=B0=D0=B2=D0=B3. 2021 =D0=B3., 14:22 Serhii Smirnov : > instead of defining constants like: > const FOO =3D 'FOO'; > > they could be defined like: > autoconst FOO; // defines a constant FOO with the value 'FOO' Sorry, but I'm not a fan of this proposal. Features should not be aiming at minor savings of keystrokes at the expense of readability and maintainability. Remember, we write code once but afterwards it might end up being read hundreds of times. This proposal makes code less readable, and unintuitively works differently from enums where cases without explicit values don't default to anything. 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' > This one saves even fewer keystrokes and harms maintainability even more: imagine you're debugging your program and you've dumped some value. You see "MyConstant". Now you search the code for the source of that value but find nothing because instead of MyConstant there's only MY_CONSTANT. > --00000000000012c42305c87e33b4--