1/49
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Expressions
___ are the fundamental means of specifying computations in a programming language.
assignment statements
Essence of imperative languages is dominant role of ___.
Arithmetic evaluation
___ was one of the motivations for the development of the first programming languages.
mathematics
Most of the characteristics of arithmetic expressions in programming languages were inherited from conventions that had evolved in ___.
unary,
binary,
ternary
An operator can be ___, meaning it has a single operand, ___, meaning it has two operands, or ___, meaning it has three operands.
arithmetic computation
The purpose of an arithmetic expression is to specify an ___.
1. Precedence
2. Associativity
3. Parenthesis
4. Expressions in Lisp
5. Conditional Expressions
Operator Evaluation Order (5 in order)
precedence
The operator ___ rules for expression evaluation define the order in which the operators of different precedence levels are evaluated.
identity operator
Unary addition (+) is called the ___ because it usually has no associated operation and thus has no effect on its operand.
unary minus
In Java and C#, ___ also causes the implicit conversion of short and byte operands to int type.
associativity
The operator ___ rules for expression evaluation define the order in which adjacent operators with the same precedence level are evaluated. An operator can be either left or right associative.
Fortran
- Typical associativity rules:
Left to right, except **, which is right to left
Sometimes unary operators associate right to left such as ___
Fortran
Associativity
A * B * C is seen in what language? ___
Ada
Associativity
(A * B) * C is seen in what language? ___
APL
___ is different; all operators have equal precedence and all operators associate right to left.
A x B + C
// A = 3, B = 4, C = 5 -> 27
parentheses
Programmers can alter the precedence and associativity rules by placing ___ in expressions.
subprograms
Lisp:
All arithmetic and logic operations are by explicitly called ___
If-then-else
These are used to perform conditonal expression assignment
Variables
Operand evaluation order:
___ fetch the value form memory
Constants
Operand evaluation order:
___ sometimes a fetch from memory; sometimes the constant in the machine language instruction and not require a memory fetch.
Parenthesized expression
Operand evaluation order:
___ evaluate all operands and operators first
functional side effect
A side effect of a function, called a ___, occurs when the function changes either one of its parameters or a global variable.
- Write the language definition to disallow functional side effects
- Write the language definition to demand that operand evaluation order be fixed
Two possible solutions to the functional side effects problem:
Java
____ guarantees that operands are evaluated in left-to-right order, eliminating this problem
operator overloading
The use of an operator for more than one purpose is ____.
Java
___ uses + for addition and for string catenation
C++
C#
F#
___, ___, and ___ allow user-defined overloaded operators
- When sensibly used, such operators can be an aid to readability (avoid method calls, expressions appear natural)
- Potential problems:
Users can define nonsense operations
Readability may suffer, even when the operators make sense
narrowing conversion
A ___ is one that converts an object to a type that cannot include all of the values of the original type e.g., double to float.
widening conversion
A ___ is one in which an object is converted to a type that can include at least approximations to all of the values of the original type e.g., int to float.
mixed-mode
A ___ expression is one that has operands of different types.
coercion
A ___ is an implicit type conversion
ML
F#
In ___ and ___, there are no coercions in expressions
casts
In the C-based languages, explicit type conversions are called ___
Java
In ___, to specify a cast, the desired type is placed in parentheses just before the expression to be converted, as in
relational operator
A ___: an operator that compares the values of its two operands
Boolean
The value of a relational expression is ___, unless it is not a type included in the language
JavaScript,
PHP
___ and ___ have two additional relational operator, === and !==
- Similar to their cousins, == and !=, except that they do not coerce their operands
C99
Versions of C prior to ___ have no Boolean type; it uses int type with 0 for false and nonzero for true.
short-circuit evaluation
A ___ of an expression is one in which the result is determined without evaluating all of the operands and/or operators.
==
The C-based languages use ____ as the equality relational operator to avoid confusion with their assignment operator
=
The operator symbol for assignment:
____ Fortran, Basic, PL/I, C, C++, Java
:=
The operator symbol for assignment:
___ ALGOL, Pascal, Ada
compound assignment operator
A ___ is a shorthand method of specifying a commonly needed form of assignment
unary operator
A ___ is called so because it operates on only one operand. The term "unary" comes from the Latin word "unus," meaning one. In programming, unary operators take a single value or operand, modify it, and return a result.
Increment Operator (++)
Decrement Operator (--)
In C-based languages, there are two special unary operators used for incrementing and decrementing a variable's value, which can be combined with assignment operations, these are?
Assignment as an Expression
This design treats the assignment operator much like any other binary operator, except that it has the side effect of changing its left operand.
difficult to read and understand.
Assignment as an Expression
Disadvantage: another kind of expression side effect which leads to expressions that are ___
Perl
Ruby
Lua
___, ___, and ___ provide multiple-target multiple-source assignments
values
Identifiers in functional languages are only names of ___
mixed-mode assignment
A ___ occurs when the value being assigned to a variable is of a different type than the variable itself. In this case, the language may automatically convert or coerce the value to the correct type before the assignment is made.