I think the code \makeatletter X\@getoptionalarg\relax[dummy] Y \resetatcatcode should not introduce a space between X and Y. But it does. Am I mistaken about how \@getoptionalarg is supposed to work? Thanks for any help with this.