Mon, 29 Apr 2013 11:50:10 -0700
|
Hello, forgive (and correct) me if I misunderstand how this command should
be used:
\DeclareDocumentCommand { \foo }
{ > { \SplitArgument { 2 } { ; } } m }
{ \my_command:nnn #1 }
As the output of '\SplitArgument' is some number of brace groups lumped
together into a '#1', it seems like a test for '-NoValue' would need to be
moved into '\my_command:nnn', i.e. from the xparse interface, into
"programmer code". As `\IfNoValueTF' is an xparse command, that doesn't
feel correct. If this is a reasonable interpretation/usage, then my
personal opinion would be that empty brace groups (or something else) would
be preferable to -NoValue-'s.
scott
On Mon, Apr 29, 2013 at 1:54 AM, Joseph Wright <
[log in to unmask]> wrote:
> Hello all,
>
> I've had a couple of reports recently of an inconsistency in the way
> \SplitArgument is documented compared to how it is implemented. In the
> current CTAN release, something like
>
> \DeclareDocumentCommand { \foo }
> { > { \SplitArgument { 2 } { ; } } m }
> { \showtokens {#1} }
> ...
> \foo{bar}
>
> gives
>
> > {bar}{-NoValue-}{-NoValue-}.
> \foo code #1->\showtokens {#1}
>
> i.e. inserts the '-NoValue-' marker, but the documentation says you
> should get
>
> > {bar}{}{}.
> \foo code #1->\showtokens {#1}
>
> i.e. empty groups.
>
> In the SVN, I have altered the behaviour to do what the docs say.
> However, this breaks some packages and more importantly may not be the
> 'best' approach. In particular, returning '-NoValue-' allows
> differentiation of
>
> \foo{bar;;} and \foo{bar}
>
> which is not possible if an empty group is returned.
>
> Conceptually, '-NoValue-' was introduced for flagging omitted optional
> arguments. Using it in \SplitArgument is therefore something of an
> extension, but at the same time the way this function works makes the
> splitting 'optional'. Thus it is quite arguable that the use of the
> special marker is entirely correct here.
>
> What do people feel is the best approach?
>
> (Note: There are some other issues related to '-NoValue-' that this
> raises, which I'll cover in a separate message.)
> --
> Joseph Wright
>
|
|
|