An addition to @egreg's answer, which I agree has a better syntax, but without xparse. The commented version is a TeX style definition of the command, and the uncommented is a LaTeX style definition. In the LaTeX definition the optional argument can only take a default value, here set to \empty, which can then be checked in the code. It should work as long as it is not loaded with \empty. The dots around the commands when used are just to check that no extra spaces are added. (Actually, the LaTeX version can probably be seen as a one-liner, but it is more readable like this:-)
\documentclass{article}
%%%% TeX style definition
% \makeatletter
% \def\sndname{\@ifnextchar[\opt@sndname\@sndnamevar}
% \def\opt@sndname[#1]{\def\@sndnamevar{#1}}
% \makeatother
%%%% LaTeX style definition
\newcommand\sndname[1][\empty]{%
\ifx#1\empty
\sndnamevar
\else
\def\sndnamevar{#1}%
\fi}
%%%% Load with nothing (just in case \sndname is used before loaded)
\sndname[]
%%%%
\begin{document}
Load: .\sndname[Name of snd].
Print: .\sndname.
\end{document}
\def\sndname{\@ifstar\@sndname{\def\@sndname}}works. – Ulrike Fischer Feb 02 '17 at 16:18