Talk:Python (programming language): Difference between revisions

Content deleted Content added
m What about Parrot ?
Formatting of C examples
Line 97:
 
[[User:Hgfernan|Hgfernan]] 22:38, 4 Sep 2004 (UTC)
 
== Formatting of C examples ==
 
An anon user removed all but the outermost braces from the example of the factorial function written in C. I have reverted it back for the time being because I'm not sure the anon's version is correct, or clear, whereas the pre-edit version is both.
 
'''''Is it correct?'''''
 
The statement blocks from which the anon removed the braces were blocks of one statement each. Since I have not written C code in a decade, my knowledge is rusty; I believe this may be technically correct, that you may omit the braces from a statement block only if there's only one statement in the block. However, I am not sure on this point.
 
'''''Is it clear?'''''
 
Even if the code as the anon edited it is compiler-correct, it is misleading; the entire point of the comparison is that Python uses indentation, as opposed to punctuation, which is what C uses in every case ''except'' single-statement blocks, where it becomes optional.
 
'''''What should we do about it?'''''
 
In the short term, I have reverted, as previously mentioned. However, in the long term, we should perhaps decide between three alternatives (assuming that omission of braces is in fact legal in C for single-statement blocks):
 
'''The code as it was before the anon edit.''' The disadvantage is that it does not show the one instance in C where a programmer may choose to omit the braces. The advantage is that it more accurately reflects the general practices of C. Since the article is about Python and not C, the disadvantages don't strike me as too significant in this case.
 
'''The code as it was after the anon edit.''' The disadvantage is that it does not show one possible way a C programmer ''might'' format their code in the one case where they have a choice. The advantage is that it is more accurate, at least in terms of how a C programmer ''might'' format (many programmers choose to format consistently in the style that is always allowed, even when they language offers a choice.)
 
'''A different example that requires multiple-statement blocks.''' The disadvantage is that it would require careful selection of a new example. The advantage is that it would not be an artificial example. This doesn't strike me as too much of an advantage; don't hundreds of computer text books demonstrate basic principles by showing the bubble sort, despite the notorious inefficiency of the bubble sort?
 
I think on the whole my recommendation is for the first alternative, but if anyone disagrees, please bring up the issue here.
 
-- [[User:Antaeus Feldspar|Antaeus Feldspar]] 18:26, 21 Sep 2004 (UTC)