Dot when used in a pattern becomes Times… Why?

 In[1] := Hold[a.b] // FullForm
Out[1] := Hold[Dot[a,b]]


So far so good.

 In[2] := Hold[a_.b_] // FullForm
Out[2] := Hold[Times[Optional[Pattern[a,Blank[]]],Pattern[b,Blank[]]]]


Why does the Dot become Times? I have a feeling it has something to do with the Optional that also appears, but I can't find anything that explains what's going on in the documentation.

See the documentation for Optional:

The special form s_. is equivalent to Optional[s_] and can be used to represent function arguments which, if omitted, should be replaced by default values globally specified for the functions in which they occur.

This explains the result your are receiving.

Thus, it seems you have a precedence problem, and a possible workaround is:

Hold[(a_).(b_)] // FullForm


and get

Hold[Dot[Pattern[a, Blank[]], Pattern[b, Blank[]]]

• Even FullForm[Hold[(a_).b_]] is enough since now there are no special forms related to . in the expression. +1. – Kuba Jan 14 '14 at 9:04
• I have never seen an application of Optional... – Murta Jan 14 '14 at 10:31
• Don't know how I missed that in the docs! Thanks. – Dan Jan 14 '14 at 16:51
• A single space will also work: Hold[a_ .b_] // FullForm. @Murta Optional is quite useful. A few examples from my own answers: (17498), (20715), (29366), (30591), (30919), (47844), (51670). – Mr.Wizard Oct 25 '14 at 1:37