[luatex] \lastnamedcs and \begincsname with empty csname

David Carlisle d.p.carlisle at gmail.com
Sun Jan 7 23:15:23 CET 2018

On 7 January 2018 at 21:34, Joseph Wright
<joseph.wright at morningstar2.co.uk> wrote:
> Hello,
> Testing out how \lastnamedcs and \begincsname behave for some LaTeX kernel
> work, the following has come up:
> \def\test#1{%
>   \expandafter\def\csname #1\endcsname{abc}
>   \message{\begincsname #1\endcsname}}
> \test{x}
> \test{y}
> \test{}
> \expandafter\let\expandafter\x\csname abc\endcsname
> \show\x
> \expandafter\show\lastnamedcs a
> \expandafter\let\expandafter\x\csname hbox\endcsname
> \show\x
> \expandafter\show\lastnamedcs b
> \expandafter\let\expandafter\x\csname\endcsname
> \show\x
> \expandafter\show\lastnamedcs c
> \end
> As you'll see, with an empty csname, both \lastnamedcs and \begincsname give
> (possibly) surprising results. Is this by-design?
> Joseph

Another example, the luatex manual, when introducing \lastnamedcs
indicates that the constructs \usea and \useb below are equivalent,
\useb (using \lastnamedcs) is noticeably quicker, but they are not
equivalent and the extra tests that #1 is empty and if so falling back
on a test of \csname\endcsname complicate the macro coding and use up
much of the speed differences.

Should not \lastnamedcs expand to the token with empty csname after
\csname\endcsname ?










a: \usea{}

b: \useb{}


More information about the luatex mailing list