RFC: autoconst

From: Date: Sun, 01 Aug 2021 11:21:48 +0000
Subject: RFC: autoconst
Groups: php.internals 
Request: Send a blank email to internals+get-115615@lists.php.net to get a copy of this message
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!

« previous php.internals (#115615) next »