I wanted to play with delimiter sizing without using the \delimiterfactor, -shortfall, etc. and made the following:
\newdimen\bigdim \bigdim = 1.9743ex
\newdimen\Bigdim \Bigdim = 2.671ex
\newdimen\biggdim \biggdim = 3.3678ex
\newdimen\Biggdim \Biggdim = 4.0646ex
\def\fence#1#2#3{
\setbox0\hbox{$\displaystyle #3$}
\ifdim\ht0 < .9\bigdim #1\box0 #2\else
\ifdim\ht0 < .9\Bigdim \bigl#1\box0\bigr#2\else
\ifdim\ht0 < .9\biggdim \Bigl#1\box0\Bigr#2\else
\ifdim\ht0 < .9\Biggdim \biggl#1\box0\biggr#2\else
\ifdim\ht0 < .9\Biggdim \Biggl#1\box0\Biggr#2\else
\left#1\box0\right#2
\fi\fi\fi\fi\fi}
\def\args(#1){\fence(){#1}}
$$
\args(bar\args(baz))
$$
\bye
(before you push that comment-button, I know there should be \mathsurround=0pt and such in there, I just wanted to keep this simple) but this results in an error saying the argument of \args has an extra }.
I thought it would have something to do with macro argument delimiters, so made a quick test:
\def\foo(#1){(#1)}
\foo(bar\foo(baz))
\bye
but that seemed to work just fine. Now I don't know what else could be the issue. Note that if there isn't an \args inside of \args, it works.
\foothen? – morbusg Aug 09 '14 at 11:29xparsefor an example which does work at the cost of a lot of effort). – Joseph Wright Aug 09 '14 at 11:33\argswithout explicitly bracing the arguments when using the macro? :) – morbusg Aug 09 '14 at 11:42(#1)it will take everything up to the first)as#1without matching anything other than{}. You see same in latex's[]delimited optional arguments. as Joseph said xparse will match()if you want but it does it by reading token by token and matching braces "by hand" – David Carlisle Aug 09 '14 at 11:45\args(bar\args(baz))? I guess the height satisfies condition 1, so the first\argsshould expand to\bigl(bar\args(baz\bigr)), then the internal\argsis expanded, and should get to\bigl(bar\bigl(baz\bigr)\bigr), but the\bigr)that seems to close the internal\argsis in fact part of its argument. So we guess the problem somehow comes from the sizing, which prevents the first)to be taken as the closing of the internal\args's argument as happens with the\foo. In all that, I don't quite see how we get anExtra }. Let's test this with … – MickG Aug 09 '14 at 20:18\foowith sizing. Result:Missing delimiter (. inserted). <to be read again> \mathclose l.5 $$\foo(bar\foo(baz) )$$, error detected between the two)s. – MickG Aug 09 '14 at 20:18\argstries to set its argument in a box so it evaluates\hbox{$\displaystyle bar\args(baz$}and if that box was set its height would be measured but the inner\argsfails with a runaway argument error as it has no)– David Carlisle Aug 09 '14 at 21:01