Book contents
- Frontmatter
- Contents
- List of Boxes
- Preface
- Part I Introduction
- Part II Action Notation
- Part III Semantic Descriptions
- Chapter 11 Statements
- Chapter 12 Literals
- Chapter 13 Expressions
- Chapter 14 Declarations
- Chapter 15 Variables
- Chapter 16 Subprograms
- Chapter 17 Tasks
- Part IV Conclusion
- Appendices
- Bibliography
- Symbol Index
- Concept Index
Chapter 13 - Expressions
Published online by Cambridge University Press: 19 January 2010
- Frontmatter
- Contents
- List of Boxes
- Preface
- Part I Introduction
- Part II Action Notation
- Part III Semantic Descriptions
- Chapter 11 Statements
- Chapter 12 Literals
- Chapter 13 Expressions
- Chapter 14 Declarations
- Chapter 15 Variables
- Chapter 16 Subprograms
- Chapter 17 Tasks
- Part IV Conclusion
- Appendices
- Bibliography
- Symbol Index
- Concept Index
Summary
Expressions include arithmetic and Boolean operations. Statements involving expressions include conditionals, while-loops, and guarded alternatives.
The semantic description of expressions and statements illustrates the use of the functional action notation introduced in Chapter 6.
Semantic entities are the same as for literals, although further operations on them are needed now.
Expressions in programming languages resemble mathematical terms. Syntactically, both expressions and terms are generally formed from literal constants, such as numerals, and variables, using mathematical operators, such as +. Semanticaily, both expressions and terms are evaluated to particular values.
There are, however, some distinctive differences between expressions and terms. Function calls in expressions may lead to divergence, whereas the application of a mathematical function in a term to arguments outside its domain of definition is merely undefined. Expression evaluation may even involve execution of statements. The notion of a program variable in an expression is quite different from that of a mathematical variable in a term, as explained in detail in Chapter 15. The order of evaluation of subexpressions in an expression may affect the value given—although in most programming languages, the order of evaluation is deliberately left implementation-dependent, which prevents program(mer)s from relying on any particular order. Whether or not a particular subexpression gets evaluated may also affect the outcome of the evaluation, and some expression constructs conditionally avoid the evaluation of particular subexpressions.
- Type
- Chapter
- Information
- Action Semantics , pp. 142 - 151Publisher: Cambridge University PressPrint publication year: 1992