Steven D'Aprano wrote:
I find it difficult to imagine a more meaningful distinction than that between syntax and semantics.

That may be so, but when specifying a programming language, there is
often some flexibility as to whether language rules are considered
part of the syntax or the semantics.

An extreme example of this is the formalism used to specify Algol 68,
where, believe it or not, things such as the fact that identifiers must
be declared in an enclosing scope are expressed in the *grammar*.

Strictly speaking, anything that makes a particular sequence of symbols
not be a valid program, that could in principle be determined by static
analysis, can be considered a syntactic issue. So classifying a
TargetScopeError as a kind of SyntaxError isn't necessarily wrong.

There's actually a precedent for this in Python already:

>>> def f():
...  nonlocal x
...  x = 5
...
  File "<stdin>", line 2
SyntaxError: no binding for nonlocal 'x' found

We seem to be happy to use a plain SyntaxError for that, not even
bothering with a subclass. So I'm inclined to agree that TargetScopeError
is not necessary.

--
Greg
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/PPHYLNGI3N5A5E5RQQTBLM2PUJB6DASC/

Reply via email to