When looking at https://tex.stackexchange.com/a/64435, it seems to me that \mathpunct{:} and \colon should be interchangeable. But with amsmath, or NewTX, or unicode-math + TeX Gyre Termes Math, they are not. The documentation of unicode-math says that \colon from amsmath is used. Why the additional spacing? What's the point?
The second line of the output of
\documentclass{article}
\pagestyle{empty}
\usepackage{iftex}
\ifTUTeX
\usepackage[math-style=ISO]{unicode-math}
\setmainfont{TeX Gyre Termes}
\setmathfont{TeX Gyre Termes Math}
\else
\usepackage{newtxtext,newtxmath}
% \usepackage{amsmath}%%% alternative
\fi
\begin{document}
\noindent
A$\mathpunct{:}$B\\
A$\colon$B\\
$A\mathpunct{:}B$\\
$A\colon B$
\end{document}
is A : B regardless of whether we compile with pdflatex or lualatex:
(Though you may or may not wish spacing in line 4.)
In particular, when \colon happens to end the line, say, \colon\\, there's some space between it and the right margin. I don't see any point in it.
By the way, how much spacing does \colon insert before and after : exactly?

\colonso that it is useful only for a particular layout in constructions such asf\colon A\to B.... It is therefore wise to always use\mathpunct{:}for the simple punctuation colon in mathematics." – Ulrike Fischer Feb 23 '23 at 19:57f\colon A\to Bmight make sense. How about formulas with quantifiers, say,\forall\, x\in X\colon\varphi? Is the spacing around : there meant to be like this? – Feb 23 '23 at 20:03$A:B$? – Werner Feb 23 '23 at 20:25\colon. – Feb 23 '23 at 20:31:gives a\mathrel. It might be what one wants, or not;-)– campa Feb 23 '23 at 20:33\mathpunct{:}everywhere it's needed, and define something like\newcommand{\hastype}{\mathpunct{:}}or similar and useA \hastype Bin your document. – Werner Feb 23 '23 at 22:48