I don't know if it's right to allow this kind of practice, but I've been asked many times. How do you allow spaces between square brackets and parentheses in the code below?
I try to use \@ifnextchar unsuccessfully, perhaps it's easier with expl3
\documentclass{standalone}
\usepackage{tikz}
\makeatletter
\def\DrawPolygon{\@ifnextchar[{\@DrawPolygon}{\@DrawPolygon[]}}
\def\@DrawPolygon[#1](#2,#3)#4{%
\begingroup
\draw[#1] (#2)
\foreach \pt in {#2,#3}{--(\pt)}--cycle;
\endgroup
}
\makeatother
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (2,0);
\coordinate (C) at (2,2);
\coordinate (D) at (0,3);
\DrawPolygon [red](A,...,D) {mypolygon} %ok
% problem with \DrawPolygon [red] (A,...,D) {mypolygon}
\end{tikzpicture}
\end{document}


