Expressions and Assignment Statements

Aydin Bagiyev
3 min readNov 13, 2020

--

1st chuck

The topic is divided into chucks and flow will be followed by the outline in each chunk.

Outline:

  1. The semantics rules that determine the order of evaluation of operators in expressions are discussed first.

Introduction

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 language.

There are 2 know issues:

  • Although the value of an expression sometimes depends on it, the order of operand evaluation in expressions is often unstated by language designers. This allows implementors to choose the order, which leads to the possibility of programs producing different results in different implementations
  • Other issues in expression semantics are type mismatches, coercions, and short-circuit evaluation

Imperative Programming Languages

  • The essence is the dominant role of assignment statements.
  • The purpose of these statements is to cause the side effect of changing the values of variables, or the state, of the program
  • So, an integral part of all imperative languages is the concept of variables whose values change during program execution

Functional Programming Languages

  • Functional languages use variables of a different sort, such as the parameters of functions.
  • These languages also have declaration statements that bind values to names.
  • These declarations are similar to assignment statements, but do not have side effects.

Arithmetic Expressions

In programming languages, arithmetic expressions consist of operators, operands, parentheses, and function calls

An operand can be

  • unary (single operand)
  • binary (two operands)
  • ternary (3 operands)

Operators can be expressed in 3 types:

  • Infix (a + b) — most of the binary operators
  • Prefix (+ab) — (++) and (- -) C-based languages
  • Postfix (ab+) — (++) and (- -) C-based languages

Arithmetic expression is to specify an arithmetic computation which is happened by 2 action:

  • Fetching the operand (usually from memory)
  • Executing arithmetic operations

--

--

No responses yet