# Basic xparse does not seem to be working

I can't seem to get basic xparse working. This seems like a bug, but this example feels so basic that I feel that there must be something I am not understanding about how to use this. Here is my test example:

\documentclass{article}
\usepackage{xparse}

\NewDocumentCommand\Row{O{} O{}}{
Token1=#1 Token2=#2\par
}

\begin{document}
\Row{A}{B} \par
\Row{C}    \par
\Row       \par
\end{document}


The output of this is

Token1= Token2=
AB
Token1= Token2=
C
Token1= Token2=

1. I want the empty {} values ONLY when the tokens are not provided (which is what I thought the 'O{}' meant) so not sure why I am ONLY seeing the default values for the first two cases.

2. Why are lines 2 and 3 showing up in the output? That seems as if I had actually declared

\NewDocumentCommand\Row{O{} O{}}{
Token1=#1 Token2=#2\par
**#1#2**
}


which is not that case.

-

Use

\documentclass{article}
\usepackage{xparse}

\NewDocumentCommand\Row{O{} O{}}{
Token1=#1 Token2=#2\par
}

\begin{document}
\Row[A][B] \par
\Row[C]    \par
\Row       \par
\end{document}


Optional arguments are supposed to be in square brackets.

The way you had it, \Row{A}{B} is seen as command \Row with NO optional arguments, followed by the text {A}{B} which will just be typeset as AB.

-
Right; you need to use g if you want optional braced groups. –  Will Robertson Apr 19 '11 at 6:39
Thanks Will. I'd much prefer to use {} instead. So, why would one prefer to use O with [] instead of G with {}? –  Peter Grill Apr 19 '11 at 18:59
Traditionally, optional arguments in LaTeX were distinguished by square brackets as opposed to curly ones. One may want to continue doing that for consistency reasons. It may be good to be able to see immediately whether and argument is mandatory or optional. –  Jan Hlavacek Apr 19 '11 at 19:16