Please enable JavaScript.
Coggle requires JavaScript to display documents.
Chapter 2: Language Design Principles PART 2 - Coggle Diagram
Chapter 2:
Language Design Principles
PART 2
Expression
Expressions are the fundamental means of specifying computations in a programming languages
Arithmetic Expressions
The purpose of an arithmetic expression is to specify an arithmetic computation
Unary
Operators that works on
single operand
Binary
Operator that works on
two operands
Ternary
Operators that include
conditional evaluation
Order of evaluation
Important to know in order to avoid the
mistakes in executing the expressions
Precedence:
Define the order in which the operators of different precedence levels are
evaluated based on the hierarchy of operator priorities.
Associativity:
When an expression contains 2 adjacent occurrences of operators with the same level of precedence, the question of which operator is evaluated first is answered by the associativity rules of the language
Subprogram
Fundamental of Subprogram
Procedures
Collections of statement that define parameterized computations
Functions
Structurally resemble procedures but are semantically modeled on mathematical functions
Parameter Passing
Methods
Pass-by-value-result
When an argument provides both input to, and output from the called function
Pass-by-result
When an argument provides an output variable to which the called function can assign a result
Pass-by-reference
Same as pass-by-value-result
Pass-by-value
When an argument provides an input value to the called function
Pass-by-name
the expression in the call is not evaluated until it is used by the
function
Direction of
data passing
Return
Data goes from subprogram
back to caller at end of execution
Call-return
Data passes in both directions : into subroutine at call and back to caller at end of execution
Call
Data goes into subprogram
only at beginning of execution
Assignment Statement
Unary assignment operators:
++ for increment
-- for decrement
Compound assignment operators:
A compound assignment operator is a shorthand method of specifying a
commonly needed form of assignment
Assignment statement provides the mechanism by which the user
can dynamically change the bindings of values to variables.
Assignment as expression
Example:
x = y = z
The value of z is assigned to y, and then value of y is assigned
to x. Finally the value of x, y and z are similar to each other.
Control Structure/
Control Statement
Compound Statement/Sequential Structure
A collection of statements & executed in sequential order that is
from the beginning (first statement) to the end (last statement).
Selection Statement
Provides the means of choosing between multiple possible execution
paths
Iterative Statements
An iterative statement is one that causes a statement or collection of statements
to be executed zero, one or more times