[Python-ideas] Allow additional separator character in variables
ncoghlan at gmail.com
Sat Nov 18 23:16:54 EST 2017
On 19 November 2017 at 13:22, Mikhail V <mikhailwas at gmail.com> wrote:
> For me, one "cheap" solution against underscores is to use
> syntax highlighting which grays them out, but if those become like
> spaces, then it becomes a bit confusing, e.g. in function with many arguments.
> Also, unfortunately, not many editors allow easy (if any) highlighting
> customisation on that level.
Changing the way editors display underscore-using variable names still
seems like a more productive direction to explore than changing the
text encoding read by the compiler. The current source code structure
is well-defined and unambiguous, so there's no clear benefit to change
things at that level, and significant downsides in terms of
complexity, forwards and backwards compatibility concerns, and high
barriers to pervasive adoption.
By contrast, if the argument for using a different Unicode character
is "Editors will reliably display Unicode hyphen characters
differently from the way they display minus signs (or vice-versa)",
then we can just as easily say "If users are finding the way that text
editors display snake_cased_names to be consistently hard to read,
then text editors should change the way that they display
snake_cased_names (or at least make it easy for users to opt-in to
displaying them differently)".
For example, they could decide to replace underscores in variable
names for display purposes with hyphens plus the underscore combining
diacritic, or the combining macron below:
Then when the cursor was placed inside the variable name, they could
revert to displaying those characters as regular underscores.
This kind of editor level modification would also extend itself well
to underscores in numeric literals, as there the appropriate
pseudo-separator shown when the literal wasn't being edited would be
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas