# Which symbol gets DownValues or OwnValues when using SetDelayed?

I have been looking at various usages of Pattern objects. Here's a number of ways to define the same thing:

mod[x_] := {x}


which gives mod DownValues. Nothing unexpected.

e : mod[_] := ReleaseHold @ (Hold[e] /. mod -> List)


This is nice, as we don't need to give the argument of mod a name now.

e_mod := ReleaseHold @ (Hold[e] /. mod -> List)


Now we don't need to specify the pattern of arguments to mod at all. However, all three lines of code give DownValues to the symbol mod.

Let's look at the FullForm:

SetDelayed[mod[Pattern[x, Blank[]]], List[x]]
SetDelayed[Pattern[e, mod[Blank[]]], ReleaseHold[ReplaceAll[Hold[e], Rule[mod, List]]]]
SetDelayed[Pattern[e, Blank[mod]], ReleaseHold[ReplaceAll[Hold[e], Rule[mod, List]]]]


The first example is nothing special, the first argument of SetDelayed has the mod head, thus mod gets the DownValues. However the next two examples have head Pattern. If we use someOtherHead instead of Pattern, (in the second definition) we will get a "function" that does this:

someOtherHead[e, mod[x]]
(* e *)


and if we add the third definition as well, then:

someOtherHead[e, mod[x, y]]
(* e *)


So clearly there are some special rules for the head Pattern.

My question is three-fold:

• How does MMA choose, which Symbol gets its DownValues in a Set or a SetDelayed? Especially I am interested in the non-standard procedure, as in my last two examples, but will be happy to get better insight in the standard case presented in my first example.

• Where is this behavior documented, if at all? I am primarily looking for references, but will happily accept answers from those who know how this works even if they cannot point me to a specific reference.

• A sub-question of the previous two: where can I find the special rules specifically for the head Pattern?

• That's an interesting take. Are you trying to say, that regardless of the FullForm, the expression e_mod is treated as an expression with Head mod, rather than Pattern? (+1 anyway) Apr 28, 2016 at 10:47