Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
(BQ) Part 2 book "Programming languages" has contents: Statement-Level control structures, expressions and assignment statements, implementing subprograms, abstract data types and encapsulation constructs, concurrency, exception handling and event handling, logic programming languages,.and other contents. | 7 Expressions and Assignment Statements 7.1 Introduction 7.2 Arithmetic Expressions 7.3 Overloaded Operators 7.4 Type Conversions 7.5 Relational and Boolean Expressions 7.6 Short-Circuit Evaluation 7.7 Assignment Statements 7.8 Mixed-Mode Assignment 317 318 Chapter 7 Expressions and Assignment Statements A s the title indicates, the topic of this chapter is expressions and assignment statements. The semantics rules that determine the order of evaluation of operators in expressions are discussed first. This is followed by an explanation of a potential problem with operand evaluation order when functions can have side effects. Overloaded operators, both predefined and user defined, are then discussed, along with their effects on the expressions in programs. Next, mixed-mode expressions are described and evaluated. This leads to the definition and evaluation of widening and narrowing type conversions, both implicit and explicit. Relational and Boolean expressions are then discussed, including the process of short-circuit evaluation. Finally, the assignment statement, from its simplest form to all of its variations, is covered, including assignments as expressions and mixed-mode assignments. Character string pattern-matching expressions were covered as a part of the material on character strings in Chapter 6, so they are not mentioned in this chapter. 7.1 Introduction Expressions are the fundamental means of specifying computations in a programming language. It is crucial for a programmer to understand both the syntax and semantics of expressions of the language being used. A formal mechanism (BNF) for describing the syntax of expressions was introduced in Chapter 3. In this chapter, the semantics of expressions are discussed. To understand expression evaluation, it is necessary to be familiar with the orders of operator and operand evaluation. The operator evaluation order of expressions is dictated by the associativity and precedence rules of the .