FACTOID # 122: If you're Dutch or Swedish, you're among the world's most likely to end up living in a retirement home. If you're Japanese, you'll probably end up living with your children.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

FACTS & STATISTICS    Simple view

  1. Select countries to view: (hold down Control key and click to select several)

     

     

    Compare:

     

     

  1. Select fact or statistic: (* = graphable)

     

     

     

  2. (OPTIONAL) Compare to statistic: (both need to be graphable)

     

     

     

  3. View result as:

     

       
(OR) SEARCH ALL encyclopedia, stats & forums:   

Encyclopedia > Sequence point

A sequence point in a programming language defines any point in a computer program's execution at which it is guaranteed that all side effects of previous evaluations will have been performed, and no side effects from subsequent evaluations have yet been performed. They are often mentioned in reference to C and C++, because the result of some expressions can depend on the order of evaluation (adding one or more sequence points is one method of ensuring a consistent result, because this restricts the possible orders of evaluation). Computer code (HTML with JavaScript) in a tool that uses syntax highlighting (colors) to help the developer see the purpose of each piece of code. ... A computer program or software program (usually abbreviated to a program) is a step-by-step list of instructions written for a particular computer architecture in a particular computer programming language. ... In computer science, a side-effect is a property of a programming language function that it modifies some state other than its return value. ... The C Programming Language, Brian Kernighan and Dennis Ritchie, the original edition that served for many years as an informal specification of the language The C programming language is a standardized imperative computer programming language developed in the early 1970s by Dennis Ritchie for use on the Unix operating system. ... C++ (generally pronounced see plus plus, IPA: ) is a general-purpose computer programming language. ...


Examples of ambiguity

Consider two functions f() and g(). The '+' operator is not a sequence point and therefore in the expression "f()+g()", it is possible that either f() or g() will be executed first. The comma operator (',') is a sequence point, and therefore in "f(),g()" the order of evaluation is defined (ie, first f(), and then g() is called). The type and value of the expression is that of g() while the value of f() is discarded. In computer science, a subroutine (function, procedure, or subprogram) is a sequence of code which performs a specific task, as part of a larger program, and is grouped as one or more statement blocks; such code is sometimes collected into software libraries. ... An expression in a programming language is a combination of values and functions or procedures, interpreted according to the particular rules of precedence and of association for a particular programming language, which computes and then returns another value. ...


Sequence points also come into play when the same variable is modified more than once. An often quoted example is the expression "i=i++", which both assigns i to itself and increments i; what is the final value of i? Language definitions might specify one of the possible behaviors or simply say the behavior is undefined (the C and C++ specifications only defines the behavior if the same variable is modified at most once between two sequence points).


Sequence points in C and C++

  1. Between evaluation of the left and right operands of the && (logical AND), || (logical OR), comma operator. For example, in the expression "*p++ != 0 && *q++ != 0", all side effects of the sub-expression *p++ != 0 are completed before any attempt to access q.
  2. 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.
  3. At the end of an expression statement ( ; ).
  4. 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.
  5. After the controlling expression is evaluated in an if/switch statement.
  6. After the controlling expression is evaluated in a while or do-while statement.
  7. After each of the 3 operands of the for statement is evaluated.
  8. At the end of a return statement.
  9. At the end of an initializer.

  Results from FactBites:
 
Sequence point - Wikipedia, the free encyclopedia (518 words)
A sequence point in a programming language defines any point in a computer program's execution at which it is guaranteed that all side effects of previous evaluations will have been performed, and no side effects from subsequent evaluations have yet been performed.
They are often mentioned in reference to C and C++, because the result of some expressions can depend on the order of evaluation (adding one or more sequence points is one method of ensuring a consistent result, because this restricts the possible orders of evaluation).
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.
PlanetMath: limit points of sequences (161 words)
It is worth noting that the set of limit points of a sequence can differ from the set of limit points of the set of elements of the sequence.
Likewise the set of accumulation points of a sequence can differ from the set of accumulation points of the set of elements of the sequence.
This is version 4 of limit points of sequences, born on 2004-09-24, modified 2005-03-02.
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.