On Fri, May 18, 2018 at 07:22:13PM +0800, Ken Hilton wrote: [...] > Only treat keywords as having any special meaning when they are in places > with syntactical significance. [...] > My idea is to only treat keywords as having special meaning when they're in > the right place.
Chris discussed his experience with REXX, which works like that: 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. [...] 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"? https://mail.python.org/pipermail/python-ideas/2018-May/050694.html I think its a no-brainer: I'd much rather get an error earlier, when I first decide its a good idea to call a method "while", rather than six months later when I stumble across a corner case that stops me from using it. I'm sure that everyone is absolutely champing at the bit to write code like: for = if if while else else or = [in or for for in in for if if] *wink* but I think we should be conservative about allowing keywords as identifiers. Requiring a clear and obvious escaping mechanism (verbatim strings \name) or a clear and obvious renaming convension (name_) is better than a context-sensitive grammar. That's even assuming such a context-sensitive grammar would be possible within the requirement that Python's parser is LL(1). -- Steve _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/