[Python-Dev] Re: Proto-PEP part 4: The wonderful third option

2022年4月26日 12:01:03 -0700

On 4/26/22 09:31, MRAB wrote:
On 2022年04月26日 06:32, Larry Hastings wrote:
Note that this spelling is also viable:
  class C
I don't like that because it looks like you've just forgotten the colon.
Perhaps:
  class C: ...
That's not a good idea. Every other place in Python where there's a statement that ends in a colon, it's followed by a nested block of code. But the point of this statement is to forward-declare C, and this statement /does not have/ a class body. Putting a colon there is misleading. Also, your suggestion is already legal Python syntax; it creates a class with no attributes. So changing this existing statement to mean something else would potentially (and I think likely) break existing code.
Consider C++'s forward-declared class statement:
 class C;
You could say about that, "I don't like that because it looks like you've just forgotten the curly braces." But we didn't forget anything, it's just new syntax for a different statement.
//arry/
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/S54FAGLEKF22T3WTLTIZ37FW3BVMJQ3V/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to