i'm not referring to how Python is today or how Python has always been. i'm referring to whether the language syntax needed to be this way. and this is not a proposal to change Python in any way. i am trying to understand the thinking behind the origin on the language. that might be the ABC language.
"The colon is required primarily to enhance readability"
if this is so then the lack of colon would detract from readability. that would not mean it has to be a part of the syntax. consider what message you get without it. does it say your code is poorly readable (by humans)?
"However, ABC’s authors did invent the use of the colon that separates the lead-in clause from the indented block"
with the colon we can form the structure. whatever we include with the colon can form the semantics. we can use "try" to mean a block of code that is under an exception catching umbrella. in order to do this, "try" and ":" must be together. "try" anywhere else would have no meaning. so why does is need to be a reserved word everywhere? why not just have it be a reserved word only when ":" is next (even when separated with spacing)?
then, there's meaning in the indentation. but this is additional meaning if we give specific meaning to a word ("try" or "for") or to punctuation (":"). now we are getting even more redundancy in semantics.
if "try:" clearly expects a block to follow, ended by a statement that begins with "except" and ends with ":", then we already know where it begins and where it ends making the indentation redundant.
"The colon is required primarily to enhance readability"
if this is so then the lack of colon would detract from readability. that would not mean it has to be a part of the syntax. consider what message you get without it. does it say your code is poorly readable (by humans)?
"However, ABC’s authors did invent the use of the colon that separates the lead-in clause from the indented block"
with the colon we can form the structure. whatever we include with the colon can form the semantics. we can use "try" to mean a block of code that is under an exception catching umbrella. in order to do this, "try" and ":" must be together. "try" anywhere else would have no meaning. so why does is need to be a reserved word everywhere? why not just have it be a reserved word only when ":" is next (even when separated with spacing)?
(Jan-28-2020, 12:03 AM)Gribouillis Wrote: You could as well argue that class and def don't need a colon.OK, i will, later. and "for" and "while", too. or i could, instead, argue, that ":" isn't needed, in general (and can be optional for enhancing readability for humans).
then, there's meaning in the indentation. but this is additional meaning if we give specific meaning to a word ("try" or "for") or to punctuation (":"). now we are getting even more redundancy in semantics.
if "try:" clearly expects a block to follow, ended by a statement that begins with "except" and ends with ":", then we already know where it begins and where it ends making the indentation redundant.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.