On Tue, Apr 7, 2020 at 5:03 AM Guido van Rossum <guido@python.org> wrote:
On Mon, Apr 6, 2020 at 11:36 AM Steven D'Aprano <steve@pearwood.info> wrote:
Personally, I would not like to have to explain to newcomers why `match` is a keyword but you can still use it as a function or variable, but not other keywords like `raise`, `in`, `def` etc.
match expression: match = True
What kind of newcomers do you have that they even notice that, unless you were to draw attention to it? I'm serious -- from the kind of questions I've seen in user forums, most newcomers are having a hard enough time learning more fundamental concepts and abstractions than the precise rules for reserved words.
From my experience of teaching a variety of languages, including SQL, it's usually not something people have a problem with in toy examples - but it becomes a major nuisance when they're trying to deal with a problem and some keyword is getting in the way. SQL is *full* of context-sensitive keywords, and every once in a while, someone uses a non-reserved word as a column name, and everything works until they run into some specific context where it doesn't work. (It's a bit messier than in Python due to multiple abstraction layers eg ORMs, and sometimes they deal with these issues and sometimes not; but it's still that much harder to debug specifically _because_ things aren't always reserved.) Ultimately it comes down to the number of edge cases that people have to learn, and how edgy those cases are. Python already has the possibility to override builtins, so you can say "list = []" without an error; context-sensitive keywords sit in a space between those and fully-reserved words. It'll come down to specific words as to whether it's inevitably going to be a problem down the track, or almost certainly going to be fine. BTW, is the PEG parser going to make it easier to hack on the language syntax? If so, it'd be that much easier to experiment with these kinds of ideas in a separate branch/fork, and quickly find out if there's going to be any major impact. At the moment, editing the grammar is a bit daunting - too many easy ways to mess it up. ChrisA