\documentclass{article}
\usepackage{xspace}
\usepackage{dsfont}
\usepackage{multidef}


%% basic definition
\multidef[p=cal]{\ensuremath{\mathcal{#1}}}{A-Z}

%% example with noerr, nowarn
\multidef[noerr,nowarn,suffix=name]{#1}{contents->Table des mati\`eres,
  ref->R\'ef\'erences,
  part->Partie}

%% with one argument
\multidef[arg=1]{\ensuremath{\mathsf{#1}(##1)}}{first,last}

%% global + robust
\makeatletter
\bgroup
\multidef[noerr,global,p=bb,args=1,robust]
         {\@ifnextchar+{\ensuremath{\mathds{#1}^+}\@gobble}
                       {\ensuremath{\mathds{#1}}}}
         {A,B,C,H,N,Q,R,T,Z,
          Z , Z ,one->1}
\egroup


\begin{document}

\section{\protect\(\bbZ\protect\) would fail if not robust}

\calT\ should write $\mathcal T$

\first a should write $\mathsf{first}(a)$

\end{document}
