Google
 
   
Login
Username:

Password:


Lost Password?

Register now!
Search
Main Menu
top books
Polls
What do you think about php-deluxe.net?
Excellent!
Cool
Hmm..not bad
What the hell is this?
encyclopedia
recommendation
compare webbrowser
Freenet DSL
Who's Online
9 user(s) are online (9 user(s) are browsing encyclopedia)

Members: 0
Guests: 9

more...
browser tip
Unix Befehle
manual of unix befehle
recommendation!
Sponsored
partner

Sequence point

A sequence point in a programming language defines any point in a computer program s Execution (computers) at which it is guaranteed that all Side-effect (computer science)s of previous evaluations will have been performed, and no side effects from subsequent evaluations have been performed. They are often mentioned in reference to C_programming_language and C plus plus, because many expressions do not define sequence points, giving potentially ambiguous results if the program is compiled on a different system.

= Examples of ambiguity =

This makes more sense given an example. Consider two functions f() and g(). + is not a sequence point and therefore in the expression (programming) f()+g() , it is possible that either f() or g() will be executed first. , is a sequence point, and therefore f(),g() will result in first f(), and then g() being executed.

The most common expression which shows the need for sequence points in C_programming_language is i=i++ . i++ denotes that after the value of i is read, its value should be increased by one. The problem is that depending on the compiler and the level of optimisation, the actual result of this expression can change (according to the ANSI C standard, such expressions are undefined, and therefore any behaviour is permissible, including Crash (computing)ing).

= Sequence points in C and C++ =

#Between evaluation of the left and right operands of the &&(logical conjunction), || (logical disjunction), comma operator. e.g. in the expression *p++ != 0 && *q++ != 0 , all side effects of the sub-expression *p++ != 0 are completed before any attempt to access q. #Between the evaluation of first operand of the ternary operator ( : ) and the second or third operand. For example, in the expression a = (*p++) (*p++) : 0 there is a sequence point after the first *p++, meaning it has already been incremented by the time the second instance is executed. #At the end of an expression statement ( ; ). #Before a function is entered in a function call. The order in which the arguments are evaluated is not defined, but this sequence point just means that all of their side effects are complete before the function is entered. In the expression f(i++) + g(j++) + h(k++) , f is called with a parameter of the original value of i, but i is incremented before entering the body of f. Similarly for j and k before entering g and h respectively. However, it is not defined in which order f(), g(), h() are executed, nor in which order i, j, k are incremented. The value of j and k in the body of f is therefore undefined. #After the controlling expression is evaluated in an if/switch statement. #After the controlling expression is evaluated in a while or do-while statement #After each of the 3 Operands of the For loop#C or C.2B.2B statement is evaluated #At the end of a return statement #At the end of an initializer#Computer Science