In mentally building a model of how Mathematica works, I naively expected
Set to create a
Rule in a symbol's
SetDelayed to create a
RuleDelayed in a symbol's
DownValues. Therefore, I was a bit surprised when I tested
ClearAll[g]; Set[g, 0]; SetDelayed[g[x_], 1]; DownValues[g] // FullForm
I naively expected to see
RuleDelayed seem semantically harmless -- at least I wasn't able to think of a breaking example before breakfast. Looking into the issue, I find the following remarks in the documentation for
HoldPattern (emphases are mine)
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.
The ambiguity of that statement signals that there is a whole lot more going on, here, meaning
SetDelayed aren't going to be exactly equivalent to the rules one would naively expect, and there must be special cases and exclusions in the works.
I'd be grateful for hints, experiences, opinions, deeper knowledge, suggested experiments, and especially pointers to clarifying documentation.