[Python-ideas] Crazy idea: allow keywords as names in certain positions
Chris Angelico
rosuav at gmail.com
Sun May 13 14:45:11 EDT 2018
On Mon, May 14, 2018 at 4:19 AM, Guido van Rossum <guido at python.org> wrote:
> The idea I had (not for the first time :-) is that in many syntactic
> positions we could just treat keywords as names, and that would free up
> these keywords.
> ...
> I should also mention that this was inspired from some messages where Tim
> Peters berated the fashion of using "reserved words", waxing nostalgically
> about the old days of Fortran (sorry, FORTRAN), which doesn't (didn't?) have
> reserved words at all (nor significant whitespace, apart from the "start in
> column 7" rule).
I spent most of the 1990s coding in REXX, which has exactly zero
reserved words. You can write code like this:
if = 1
then = "spam"
else = "ham"
if if then then
else else
do = 5
do do
print("Doobee doobee doo"
end
The problem is that you can go a long way down the road of using a
particular name, only to find that suddenly you can't use it in some
particular context. Common words like "if" and "do" are basically
never going to get reused (so there's no benefit over having actual
keywords), but with less common words (which would include the
proposed "where" for binding expressions), it's entirely possible to
get badly bitten.
So the question is: Is it better to be able to use a keyword as an
identifier for a while, and then run into trouble later, or would you
prefer to be told straight away "no, sorry, pick a different name"?
ChrisA
More information about the Python-ideas
mailing list