With vs. Block example
One basic example that even new user often struggle is to insert values of parameters into an analytic solution. Let's say we have something like this
solution = DSolveValue[{y'[x] + y[x] == a Sin[x], y[0] == b}, y[x], x]
(* Out[1]= -(1/2) E^-x (-a - 2 b + a E^x Cos[x] - a E^x Sin[x]) *)
If you now want to insert values for a and b, the usual way is to use a replacement rule {a->aValue, b->bValue}. Nevertheless, users might try to insert values using
With[{a = 1, b = 1},
solution
]
(* Out[6]= -(1/2) E^-x (-a - 2 b + a E^x Cos[x] - a E^x Sin[x]) *)
which fails. As Leonid already wrote With "does all the replacements before the body evaluates" and this makes the approach fail. Module cannot be used as well, because it uses lexical scoping that introduces new variable names that only look like normal a and b. Block, however, can be used
Block[{a = 1, b = 1},
solution
]
(* Out[7]= -(1/2) E^-x (-3 + E^x Cos[x] - E^x Sin[x]) *)
Although in general, using replacement rules is the better alternative, for some cases this gives a good alternative.