InlineVariableInExpressionTree
DRAFT

Misconception:

For an expression involving a variable, the expression tree inlines the expression tree of the expression in which that variable was assigned a value.

Incorrect

The expression tree of an expression involving a variable inlines the variable's definition

Correct

The expression tree of an expression involving a variable shows a node for that variable

Correction
Here is what's right.

The expression tree represents a syntactic decomposition of an expression (a parse tree, or abstract syntax tree, of the expression). How the value of a variable was computed is not visible in an expression tree showing a read access of that variable.

For example:

int v = 1 + 2;
int result = v + 4;

The expression v + 4 should consist of only three nodes: ”+”, “v”, and “4”. Students holding this misconception will inline the expression used to assign a value to v, and thus draw an expression tree involving 5 nodes: ”+”, ”+”, “1”, “2”, and “4”.

Language

Java
Notional Machine
ExpressionAsTree

Concepts

Expressible In

Related Misconceptions

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.