Why Optional in Set is not held by the HoldFirst attribute?

When evaluatingf[x_:x0] := x, x0 will be evaluated, regardless of the HoldAll attribute of SetDelayed.

Why the second argument of Optional is evaluated in a non-standard manner?

• Can you show us how the evaluation is non-standard? – berniethejet Feb 29 '20 at 15:09
• – xzczd Feb 29 '20 at 15:46

From the "Details" of the docs for HoldPattern

The left-hand sides of rules are usually evaluated, as are parts of the left-hand sides of assignments. You can use HoldPattern to stop any part from being evaluated.

Application:

ClearAll[f];
f[HoldPattern[x_: x0]] := x;

x0 = 7;

f[5]
f[]
(*
5
7
*)

Block[{x0 = 3},
f[]
]
(*  3  *)