[Python-ideas] Making colons optional?

Riobard Zhan yaogzhan at gmail.com
Mon Feb 9 03:36:07 CET 2009


On 8-Feb-09, at 2:18 PM, Bruce Leban wrote:
> Your statement that no programming language used trailing colons is  
> simply false. I and many others have said that colons and semicolons  
> have completely different semantics as well and you have chosen to  
> ignore that.

I apologize for the imprecise statement. It would be more precise if I  
say Python is one of the very, very few languages that require  
trailing colons. In either case, Smalltalk's colons are completely  
different animals (they signify keywords, which are used to build  
control constructs via message passing) than Python, and it makes no  
sense to compare the two. And Smalltalk is not as widespread as many  
other "mainstream" languages; therefore it is rather an exception for  
Python to require trailing colons (but not so to require commas). That  
is the difference between making colons optional and making commas  
optional; that is also why I think your generalization to commas will  
not work.

I fully understand your view that semicolons and colons are somehow  
different in semantic. It is just that you and many others have chosen  
to ignore the fact that different semantics do not necessarily imply  
different rules, otherwise we will have too many rules to worry about.  
In this case, I do not think the difference between their semantics is  
huge enough to treat them differently.



> Clearly the use of the specific semicolon character is confusing  
> you. So let's replace it with a better symbol: \n as in this example:
>
>  for i in x: foo(i) \n bar(i+1)
>
> Sure a \n is optional at the end of any line because a blank line is  
> always allowed. So what?
>
> What's the point you are trying to make?
>
> The point is that the \n token and the : token have different  
> semantics entirely. The \n token is used to separate statements on a  
> single line. You seem to think that they are related because they  
> look similar and now they don't.
>
> One more final point: in some languages, the semicolon is a  
> statement TERMINATOR as it is in C and in others it is a statement  
> SEPARATOR as it is in Pascal. I think your time would be better  
> served by working to convince the Pascal people and the C people to  
> reconcile that inconsistency than this discussion.


I think you misunderstood my point of relating semicolons and colons.  
My point is that colons are not so much different than semicolons as  
visual indicators that they deserve a different rule than semicolons  
(with one being mandatory while the other optional), because we  
already have indentation as a very effective visual indicator to tell  
us everything we need to be told. 



More information about the Python-ideas mailing list