Monday, November 27, 2017

Session 5

Session 5

Saturday, 21 October 2017


Today is the fifth session of Programming Language Concept. Today, there'll be 3 group presentations. Group 2 presentation about last session topic that got delayed, group 3 and 4 presentation about today's topic "Expression & Assignment Statements".

This session, miss Yanfi gives us a concept map to make study easier. The concept map contains all of the important point from "Expression & Assignment Statements" topic.

In this session we learned about boolean expression, arithmetic expression, relational expression and short circuit evaluation.

Arithmetic expression consists of operators, operands, parenthesis and function calls. There are 3 type of operators : unary, binary and ternary. Unary operator has one operand, binary operator has two operands and ternary operator has three operands. In arithmetic expression, there are operator precedence rules, rules that define the order of operation based on operators. The precedence level :
– parentheses
– unary operators
– ** (if the language supports it)
– *, /
– +, -
When an arithmetic expression have 2 or more operators that have the same precedence level, Associativity rules are used. In associativity rules, arithmetic expression are executed from left to right in most language.

Overloaded operator is operator that is used for more than one purpose.

Operand evaluation order :
  1. Variables: fetch the value from memory 
  2. Constants: sometimes a fetch from memory; sometimes the constant is in the machine language instruction 
  3. Parenthesized expressions: evaluate all operands and operators first The most interesting case is when an operand is a function call    
There are 2 types of type conversion : narrowing and widening. Narrowing conversion converts an object to a type that cannot include all of the values of the original type e.g. float to int. Widening conversion converts an object to a type that include at least approximations to all of the values e.g. int to float. An implicit type conversion is called coercion.

Relational expression use relational operators and operands of various types. The result of relational expression is boolean(true or false). 

Boolean expression has operator(function call) and operand(boolean) and the result is boolean(true or false).

Short circuit evaluation is an expression in which the result is determined without evaluating all of the operands and/or operators.

That's all for this session.


No comments:

Post a Comment