I am surprised that you called this proposal makes code less readable. Which code is more readable:
const SOME_LONG_NAMED_CONSTATN_FROM_ENVIRONMENT = 'SOME_LONG_NAMED_COSNTATN_FROM_ENVIRONMENT'; or autoconst SOME_LONG_NAMED_CONSTATN_FROM_ENVIRONMENT; ? Also, could you see a typo error in the classic const definition? > 1 авг. 2021 г., в 15:00, Max Semenik <maxsem.w...@gmail.com> написал(а): > > вс, 1 авг. 2021 г., 14:22 Serhii Smirnov <free.smile...@gmail.com > <mailto:free.smile...@gmail.com>>: > instead of defining constants like: > const FOO = '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.