Lecture 2: expressions, assignment, control
- types
- assignment
- expressions
- control flow: if & while
types and declarations
- All variables have a type
- initialization <--> define
assignment
- lvalue = rvalue
- types must match
- rvalue may be a value or an expression or a function evaluation
- assignment returns a value (the lvalue)
expressions
- consists of primitives, operators, expressiosn
- expressions in Scheme -- precedence doesn't matter
- infix notation in C++ -- precedence matters
- operators: arithmetic, memory, increment, ternary
- *MUST* remember precedence rules
- nonmatching types is a COMPILER error
control flow
- if (bool) { code } else { code }
- else, else if (compare to cond)
- if in C and Scheme (value vs. control>
- if and ?: in C (control vs. value)