digitalmars.D - Re: One year of Go
- Kagamin <spam here.lot> Nov 13 2010
- bearophile <bearophileHUGS lycos.com> Nov 13 2010
- Kagamin <spam here.lot> Nov 13 2010
- bearophile <bearophileHUGS lycos.com> Nov 13 2010
bearophile Wrote:Kagamin:How do you look at necessary curly braces in Go? Shouldn't they adopt python syntax while keeping Go design?
I like Python syntax, but the features of a language must be all adapted to each other, they form something like an ecology. In general what I look for is a language syntax that is somehow resilient against simple mistakes that mammals do all the time. So curly braces are sometimes better than bug-prone alternatives.
Aren't curly braces the same redundancy as semicolons, serving the same purpose?
Nov 13 2010
Kagamin:Aren't curly braces the same redundancy as semicolons, serving the same purpose?
The information represented by the curly braces is represented by the indentation levels. The semicolons are not necessary to represent logical nesting, and indeed some Python-style languages avoid them. The semicolons were added by Guido V.R. because an usability test on the ABC language (that's the base for Python) has shown they improve readability, they help the mammals that write the program. Bye, bearophile
Nov 13 2010
bearophile Wrote:Kagamin:Aren't curly braces the same redundancy as semicolons, serving the same purpose?
The information represented by the curly braces is represented by the indentation levels.
http://docs.python.org/py3k/reference/lexical_analysis.html#explicit-line-joining If understood it correctly, physical lines don't obey the indentation rules and can have any indentation, e.g. the same indentation as the return statement in the example.
Nov 13 2010
Kagamin:http://docs.python.org/py3k/reference/lexical_analysis.html#explicit-line-joining If understood it correctly, physical lines don't obey the indentation rules and can have any indentation, e.g. the same indentation as the return statement in the example.
Right. There are two exceptions to the rule: you may use the \ symbol to extend a logical line, so here the indentation doesn't matter. And the same happens inside a () [] or {}. In practice the \ are uncommon in good Python programs, the programmer usually just adds a (). Bye, bearophile
Nov 13 2010