On 16/02/2011, at 11:58 PM, Bruno Le Floch wrote:

> As I now understand, the key point in all of this is that we can
> detect spaces and braces expandably using delimited arguments, and we
> can then be sure to act on one token at a time.

Ah, I see:

    \long\gdef\UL_brace_check:nw#1#2#{%
      \UL_if_empty:nTF{#2}%
      {\UL_brace_yes:nn{#1}}%
      {\UL_space_check:nw{#1}#2}%
    }

This is clever. Has anyone seen this done before? Are there any downsides?

If it's as good as it seems then it allows all sorts of expandable things, such as optional argument parsing and expandable nested mapping.

Thanks!
-- Will