Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115618 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 94892 invoked from network); 1 Aug 2021 11:43:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Aug 2021 11:43:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id ED34518033A for ; Sun, 1 Aug 2021 05:11:38 -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.6 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (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:11:38 -0700 (PDT) Received: by mail-lj1-f173.google.com with SMTP id a7so20151713ljq.11 for ; Sun, 01 Aug 2021 05:11:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=kg5MUZPVclx3cI3dsEtyirzNMBQmoNFFM2pJVP353uA=; b=B/uk6Rf8YuxNODU0WoQvKL8Og+mmU5ijU51/ZjEuEBvt7OouFiOGYJb6DE84VyiKZ/ 660TUSJcwNa9JUVyWGm7zhDlvzwa3sd6Ny0/Y6BH6VWtDMwEsJpq+uDI1zx8AmYJfIHg wKgVNY41OIY0GWYbplR+AUaEdgouZ3te8yrCPKip7yP63LmmeJD6YWZewaMPfYP289R7 YtuGxaX6cPlGiib04BkjxfAwUD3xGhQr4uum4yQGY9vQAhnAvkkcSVjFXTwBDZSNQ1Ra e5ppHQm3mJZAefWZ4bNY8OCiqRYGk49nV8774Z9OP/XOqvh5fqJvoAzlz7X3fCr/neZK UakA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=kg5MUZPVclx3cI3dsEtyirzNMBQmoNFFM2pJVP353uA=; b=GHJkhKugWGxt6ltpDA/PzVERnzuPkHA4Wizl4EbG+9b+n5s3jLo0pz8Au7mWhZRrp1 iUiH6RDnLLgpf1fZHNVCFp+tWmT9RPytucfcLdAM2awGeMKSsKTk/DBZAQm8YmsddHMx EH+rgUW/3GZkJvpeS1fVAArQum6XnayUs6HECsRn3k+i5GQ0+Hcy0uqnHZcY+R4B/+Uu 4g+XzLhFneH2DZbi2OSMEp2QMO3IA6xH+lT+HjYl/0OglP6HXrLD49KPD/jsKzZTAWDe 7SIqrTS6a1FQBkSqgT8ZIVzAvMo1wcc6/SQ4N1hyeThefpz7CucLNLE7kDMHcmjoPeDb mpAA== X-Gm-Message-State: AOAM533WetPaf/b9RV8tMWgaA/HLAtGKvp/RYmiklEIbah9Hgcd3Xvb6 ZXCji00p84dInwusySuyipQ= X-Google-Smtp-Source: ABdhPJxYrQ9VbvFNrKtzcbFhp/1IO1awQy00YFZEpm++wS4/jTo1kJR7tiRwj91sYtd01DuoMSviaQ== X-Received: by 2002:a2e:91cb:: with SMTP id u11mr8211563ljg.262.1627819895064; Sun, 01 Aug 2021 05:11:35 -0700 (PDT) Received: from smtpclient.apple ([195.3.159.227]) by smtp.gmail.com with ESMTPSA id h9sm609795ljo.77.2021.08.01.05.11.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Aug 2021 05:11:34 -0700 (PDT) Message-ID: <0B7E886D-C78B-4001-9228-27AB25CEA18A@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_1E82198F-F8B9-45BE-B6E0-E33E86E36D1E" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Date: Sun, 1 Aug 2021 15:11:33 +0300 In-Reply-To: Cc: Internals To: Max Semenik References: <22EF92EC-C5A3-498E-9EFD-DE2B5B204BB7@gmail.com> X-Mailer: Apple Mail (2.3654.120.0.1.13) Subject: Re: [PHP-DEV] RFC: autoconst From: free.smilesrg@gmail.com (Serhii Smirnov) --Apple-Mail=_1E82198F-F8B9-45BE-B6E0-E33E86E36D1E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 I am surprised that you called this proposal makes code less readable. = Which code is more readable: const SOME_LONG_NAMED_CONSTATN_FROM_ENVIRONMENT =3D = 'SOME_LONG_NAMED_COSNTATN_FROM_ENVIRONMENT'; or=20 autoconst SOME_LONG_NAMED_CONSTATN_FROM_ENVIRONMENT; ? Also, could you see a typo error in the classic const definition? > 1 =D0=B0=D0=B2=D0=B3. 2021 =D0=B3., =D0=B2 15:00, Max Semenik = =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0=B0)= : >=20 > =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'; >=20 > they could be defined like: > autoconst FOO; // defines a constant FOO with the value 'FOO' >=20 > 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. >=20 > 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'; >=20 > 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' >=20 > 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. --Apple-Mail=_1E82198F-F8B9-45BE-B6E0-E33E86E36D1E--