# (1) macro argument to the left or (2) macro argument until end of the group

This is what I want to achieve:

{ 2 \pow -(n+4) } --> {2^{-(n+4)}}


This is what I know how to do:

\def\pow#1#2{{{#1}^{#2}}}


This is what I don't like about it:

\pow{2}{-(n+4)} is ugly to me.


Now, I know that plain TeX can do things like this due to:

\over, \choose, \above


However:

\show\over


"shows that such commands are internals."

I have dug into the TeX book (chapter 20), but do not see examples of how arguments can be to the left, i.e. I want something like:

\def #1\pow #2 {{#1}^{#2}}


Then, I tried things like:

\def \pow #1 \} {^{#1}\}}


However, neither of these work. Is it possible to define pow s.t.

{ 2 \pow -(n+4) } --> {2^{-(n+4)}}

-
\over is a primitive, and therefore does not implement the syntax in macros. Alexey's solution may work for you, but in TeX arguments have to come after the macro processing them (so in your case more complex 'before' parts may go wrong). – Joseph Wright Aug 18 '11 at 10:18

\newtoks \powtoks
\def \pow {\afterassignment\powhelp \powtoks=\bgroup }
\def \powhelp{^{\the\powtoks} \egroup }

-