Skip to main content
7 of 9
Emphasized words
dan7geo
  • 1.4k
  • 8
  • 14

Executing Trace on an expression reveals what is actually happening:

Trace[Remove@x; x = 1]
(*{Remove[Removed[x]];Removed[x]=1,{Remove[Removed[x]],Null},{Removed[x]=1,1},1}*)

"the Wolfram Language always reads in a complete input expression, and interprets the names in it, before it executes any part of the expression." (see: https://reference.wolfram.com/language/tutorial/SettingUpWolframLanguagePackages.html)

The whole line is one expression with the head CompoundExpression. The variable x gets replaced with Removed["x"] throughout that expression. Then it seems that Removed["x"] is assigned the value 1 (can someone clarify what is happening here?).

However, when you write it on two different lines, it is interpreted as two separate expressions and hence you don't face this problem.

dan7geo
  • 1.4k
  • 8
  • 14