Re: Go ahead. Stop programming. This ensures you from any mistakes.
- From: Göran Andersson <guffa@xxxxxxxxx>
- Date: Sat, 09 Jun 2007 15:21:02 +0200
valentin tihomirov wrote:
It is a fact that statements are executed seqientially, one after another.
Actually, it's not. Statements can be, and some definitely are, executed in parallell or out of sequence, as long as the result in every relevant aspect is the same as if they were executed in the sequence specified in the code.
It is truth that a block of instructions is executed as one statement. It is truth that the variables in the imerative languages, which allow deferred declarations, are visible only past declaration.
Not really. By design the variable is visible in the entire block in the sense that you can not declare another variable with the same name.
Acquiring these basic matters, everybody understands that the parent block variables declared past the block are not visible inside the block and that the block internal variables are not visible past the block. The other considerations are irrationale.
No, they are most definitely rational.
Rearranging code always can yeild errors. Does this argument give me power to infer arbitrary rules?
Now you are not being irrational. The rules are not arbitrary at all. They are definitely relevant to the situation.
I suppose that the first thing the programmers should know is the sequence of instruction execution.
It's not a matter of knowing how it works, but rather having a language that lets you easily produce stable code.
Normally, the statements are eveluated sequentially. Should we put an explicit branch after each and every statement to avoid the natural "fall through"? The fallthrough ban does not save you from the infinite kinds of errors you still can make, including wrong branching. It just infers a fair amount of code where it is unnecessariy.
In a switch statement you are jumping into one of many code blocks, it's not at all unreasonable that each block should end with a statement that specifies where the execution should continue. After all, in the majority of cases the block will end with a break anyway.
This requirement adds a bit of unnecessary code in a few cases, but a bit of unnecessary code is very often used to keep the language consistent and clear. The keyword if, for example, is always followed by a parenthesis, so the parenthesis is really totally unnecessary, but you wouldn't argue that it should be removed or even optional, would you?
--
Göran Andersson
_____
http://www.guffa.com
.
- Follow-Ups:
- Re: Go ahead. Stop programming. This ensures you from any mistakes.
- From: valentin tihomirov
- Re: Go ahead. Stop programming. This ensures you from any mistakes.
- References:
- already used in a 'child' scope to denote something else
- From: valentin tihomirov
- Re: already used in a 'child' scope to denote something else
- From: Jon Skeet [C# MVP]
- Go ahead. Stop programming. This ensures you from any mistakes.
- From: valentin tihomirov
- already used in a 'child' scope to denote something else
- Prev by Date: Re: Find the type of the exception
- Next by Date: Re: Difference, == and Object.Equals
- Previous by thread: Re: Go ahead. Stop programming. This ensures you from any mistakes.
- Next by thread: Re: Go ahead. Stop programming. This ensures you from any mistakes.
- Index(es):
Relevant Pages
|
Loading