ConditionalIsSequence
DRAFT
Not Observed

Misconception:

One if () then else block is equivalent to sequence of two if () then blocks.

Incorrect

If-then-else block is equivalent to sequence of two if-then blocks

Correct

If-then-else block can behave differently from sequence of two if-then blocks

Correction
Here is what's right.

An if-then-else block executes only one of the two bodies:

A sequence of two if-then-blocks, however, may execute both bodies:

Why? Because of Mutable State!

The value of the condition may change between the two tests. This is because in Scratch the value of variables can change over time.

The if-then-else block checks the condition only once, before it executes any of its contained blocks.

With a sequence of two if-then blocks, the condition is evaluated twice.

These two scripts can behave differently! The value of the condition changes between the two tests.

Origin
Where could this misconception come from?

NOTE — We are not aware of repeated observations of this misconception in Scratch. We documented it, for completeness, based on observations of an equivalent misconception in other languages.

Symptoms
How do you know your students might have this misconception?

This misconception can be detected by asking students to draw a control-flow graph.

Value
How can you build on this misconception?

This misconception might be a could opportunity to discuss mutability.

If Scratch did not support mutable state (variables that can have different values at different points in time), only one of the two conditions, c and not c, count be true, even if they were tested at different points in time.

However, Scratch supports mutable state. Variables and sprites can change state over time. Thus, at different times the same expression (i.e., c) may evaluate to different values. Thus, if the value of c changes between the time we evaluate c and the time we evaluate not c, both conditions might be true.

There are languages that have no mutable state; in those languages this misconception does not exist.

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.