I want to define a command, call it \dotted, that adds a period at the right place next to certain other math characters*: to the right of function-like tokens, i.e. Ord and Op, and to the left of operator-like ones, i.e., Bin and Rel. This "meta-operator" should of course preserve the spacing of the original "operator". I came up with the following preliminary solution:
\documentclass{article}
\newcommand{\dottedord}[1]{\mathord{#1.}}
\newcommand{\dottedop}[1]{\mathop{#1.}}
\newcommand{\dottedbin}[1]{\mathbin{.#1}}
\newcommand{\dottedrel}[1]{\mathrel{.}#1}
\begin{document}
\[x = \dottedord{\sigma}(y) \qquad x = \sigma(y)\]
\[x = \dottedop{\log}(y) \qquad x = \log(y)\]
\[x = y \dottedbin{+} z \qquad x = y + z\]
% This case is special...
\[x \dottedrel{=} y \qquad x \mathrel{.=} y \qquad x = y\]
\end{document}
How can I unify the four commands into one, dispatching on the type of the argument -- is there something like \mathchoice for math types? And why do I need to place the argument of \dottedrel outside \mathrel to get satisfactory spacing?
If there's something more fundamental to improve, I'd be happy to hear about that as well, of course.
*This is Julia's syntax for vectorization or "broadcasting", which can be applied to all functions and operators, but that's not really relevant here.


\broadcast[ord]{\sigma}and use\csnameto generate the\mathordcommand from that. – Davislor May 13 '19 at 21:41\arrayplus,\arrayassign, etc. – Davislor May 13 '19 at 22:37\mathord{\sigma.}or\mathop{.+}, in my opinion. The question you linked to seems to be asking the same thing, but -- though I don't really understand the expl3 stuff -- it still seems to check a fixed, given list of symbols... – phipsgabler May 14 '19 at 08:54