[NTG-pdftex] \expanded

Taco Hoekwater taco at elvenkind.com
Mon Dec 10 11:44:34 CET 2007


Heiko Oberdiek wrote:
> Hello,
>
> On Sun, Dec 09, 2007 at 08:14:31PM +0100, Morten Høgholm wrote:
>
>> Usually the x expansion meant "uses \edef" and so they were all
>> non-expandable. But now that we have pdfeTeX'ed the l3 kernel, we have
>> functions doing full expansion like \numexpr and friends and \pdfstrcmp
>> (does \edef on both arguments) used in \tlist_if_eq:xxTF. This reminds me:
>> the notes from the Oldenburg meeting mentions an \expanded primitive:
>>   \expanded <general text>
>>   Expandable command returning the full expansion
>>   of the tokens in <general text>.
>> So since this pretty much exists inside \pdfstrcmp as it is now, it could

Can someone please post an example of intended use in the
l3 kernel in "plain"-style, just so I understand the usage?

>> Any opinions from the ConTeXt/pdfTeX people here?

ConTeXt's \expanded macro expands its argument fully except
for the very first item in it, which is handy for macros that
need expanded arguments, so I assume the actual goals are very
similar. Its definition is essentially this:

\def\expanded#1{\edef\lastexpanded{\noexpand#1}\lastexpanded}

With the new primitive, it could be rewritten as:

\let\normalexpanded\expanded
\def\expanded{\afterassignment\doexpanded\let\next=}
\def\doexpanded{\normalexpanded\bgroup\noexpand}

> Biggest problem is probably a good name:
> a) \expanded would be a nice name, but it clashes with ConTeXt.
>    I remember trouble with \unexpanded :-(
> b) It would belong to e-TeX, but there isn't a e-TeX prefix:
>    \etexexpanded or \etexexpand
> c) pdfTeX's convention with prefix "\pdf" (see \pdfstrcmp, \pdfescape*):
>    \pdfexpanded or \pdfexpand
> d) longer names
>
> My preference is c) to avoid trouble with macro name clashes.
> I can live with a), then my package etexcmds would get a
> new macro \etex at expanded.

Hans and I think a) would be fine. c) is somewhat silly as it is
not related to pdftex, and also a) combines nicely with the already
present \unexpanded.

Best wishes,
Taco