Currently I use the following to type singleton sets:
\documentclass{article}\newcommand*{\singleton}[2][]{\mathopen{#1\{}#2\mathclose{#1\}}}\begin{document}$\singleton x$, but $\singleton[\big]{(x, y)}$\end{document}I recently noticed that mathtools provides DeclarePairedDelimiter with the exact same interface, but with a somewhat weird implementation.
\DeclarePairedDelimiter:macro:#1#2#3->\@ifdefinable {#1}{\MT_delim_default_inner_wrappers:n {#1}\@namedef {MT_delim_\MH_cs_to_str:N #1_star:}##1{\@nameuse {MT_delim_\MH_cs_to_str:N #1_star_wrapper:nnn}{\left #2}{##1}{\right #3}}\@xp \@xp \@xp \newcommand \@xp \csname MT_delim_\MH_cs_to_str:N #1_nostar:\endcsname [2][\\@gobble]{\def \@tempa {\\@gobble}\def \@tempb {##1}\ifx \@tempa \@tempb \@nameuse {MT_delim_\MH_cs_to_str:N #1_nostarnonscaled_wrapper:nnn}{#2}{##2}{#3}\else \MT_etb_ifblank:nnn {##1}{\@nameuse {MT_delim_\MH_cs_to_str:N #1_nostarnonscaled_wrapper:nnn}{#2}{##2}{#3}}{\@nameuse {MT_delim_\MH_cs_to_str:N #1_nostarscaled_wrapper:nnn}{\@nameuse {\MH_cs_to_str:N ##1l}#2}{##2}{\@nameuse {\MH_cs_to_str:N ##1r}#3}}\fi }\DeclareRobustCommand {#1}{\@ifstar {\@nameuse {MT_delim_\MH_cs_to_str:N #1_star:}}{\@nameuse {MT_delim_\MH_cs_to_str:N #1_nostar:}}}}(This is given by running latexdef -p mathtools DeclarePairedDelimiter in a shell.)
I would rather not import a package I don't understand the behavior of, if not necessary.Is there any reason to use mathtools rather than my custom implementation? May the latter cause bugs or unexpected outputs?