For SetDelayed, the kernel first makes the substitution literally, then does the further evaluation process if necessary.

enter image description here

I always think of SetDelayed and related functions as global rule-replacing, in contrary to the local rule-replacing, namely, ReplaceAll. However, such symmetry does not correspond so parallelly.

x + x + x + x /. x -> 3

The kernel first evaluates the left hand side expression to 4 x, then applys the substitution. So my question occurs, is there a simple build-in mechanism that literally substitutes first, then does the possible further evaluation latter? If not, what is the easy and elegant way to do it by ourselves?


2 Answers 2


Another way:

Unevaluated[x + x + x + x] /. x -> 3

A couple possibilities:

Trace @ With[{x = 3}, x + x + x + x]


Trace @ ReleaseHold[Hold[x + x + x + x] /. x->3]

{{{x->3,x->3},Hold[x+x+x+x]/. x->3,Hold[3+3+3+3]},ReleaseHold[Hold[3+3+3+3]],3+3+3+3,12}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.