Clarification
\documentclass[fleqn]{article}
\def\foo{What do I put here???}
\begin{document}
\[a \foo b\]
\[\foo b\]
\[a, \foo b\]
\[a, b\]
\end{document}
I would like the document just above to be equivalent to the following one. What should I put as a definition for the \foo command?
\documentclass[fleqn]{article}
\usepackage{amsmath}
\begin{document}
\[a\quad{}\forall{}b\]
\[\forall{}b\]
\[a,\forall{}b\]
\[a,\;\forall{}b\]
\end{document}
Original question
How can I reproduce the spacing behaviour of, the + operator in math mode, but with different spacing.
\documentclass[fleqn]{article}
\begin{document}
\[a + b\]
\[+ b\]
\[a, + b\]
\[a, b\]
\end{document}
In the document above, + has a space on either side in a + b, but has no space before or after in + b. How can I write a command with a spacing behaviour similar to +, that is having different spacing size depending on what's before (and what's after, too, if possible)?
I thought about using flexible glue, but I think it's a feature to have a space which can vary depending on how full the line is, instead of a space which varies depending on the surrounding tokens.
Note: I'm not looking for \operatorname{}. Instead, I'm trying to re-implement it, but with different spacing.

+is defined as a binary operator, so you might try defining your new "operator" as\mathbin{xx}and letting the built-in rules take over. – barbara beeton May 29 '15 at 15:51\mathbin, then? Like, have it output a\quadeither side, instead of just a normal math space? – Suzanne Soy May 29 '15 at 15:53+is a\mathbin. It's behavior is hard-coded in the TeX engine. If you want the same behavior for a different symbol, then put it in\mathbin{...}. – Heiko Oberdiek May 29 '15 at 15:54\thinmuskip,\medmuskipand\thickmuskipis used in a formula. So, if you define something to produce a\mathrelatom, it will be surrounded by\thickmuskipdetermined from the value current at the end of the formula. – egreg May 29 '15 at 15:55\medmuskip(used in\>). – Heiko Oberdiek May 29 '15 at 15:55a+b-- the+symbol (an object of typemathbin) is located between two objects of typemathord; in consequence,+is treated as a binary operator and whitespace in the amount of\medmuskipis inserted on either side. In the second example,+is not preceded by any (math) object and is thus treated as aunaryoperator, i.e., no whitespace is inserted between+andb. You'll have to pick up a copy of the TeXbook to get a hold of all possible combinations and of the associated spacing rules. – Mico May 29 '15 at 15:56\mathbinand co. is hardcoded into TeX, and one can't create similar behaviour with different spacing and conditions. Did I understand correctly? – Suzanne Soy May 29 '15 at 16:01