LATEX-L Archives

Mailing list for the LaTeX3 project


Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Bruno Le Floch <[log in to unmask]>
Fri, 24 Aug 2012 06:51:28 +0200
text/plain (56 lines)
Hello Joel,

> Iím following the LaTeX3 bug tracker, and saw the issue about
> `\lua_now:x` being renamed to `\lua_now_x:n`.
> I suspect the explanation will be over my head, but since I haven't
> seen this discussed on this list or explained in the l3 docs I figure
> someone's got to ask:
> What's the difference between the `:x` signature and the `_x:n`
> suffix+signature?

We have recently been more careful about naming variants, so that
`\foo_bar:x` is always equivalent to `\exp_args:Nx \foo_bar:n`.  Some
`x` variants are optimized, for instance `\use:x`, but this function
is still equivalent to `\exp_args:Nx \use:n` in all cases.

There are a few situations where primitives provide x-like expansion:
at the moment I can think of

- `\write` and `\immediate \write`, which expand the text to be
written when they write it.

- `\pdfstrcmp`, which expands two brace groups and compares the
resulting strings.

- `\directlua`, which expands one brace group before turing it to a
string and passing it to Lua.

The full expansion that is performed by those primitives is different
from normal `x`-expansion in a subtle way. `\use:x { ...##... }` gives
only one macro parameter token `#`, and `\use:x { ...#... }` is an
error, while with engine `x`-like expansion, `\pdfstrcmp{#}{}` is
valid.  There is also a much more obvious difference: `x`-expansion
cannot be done expandably, meaning that it may not appear within
another `x`-expansion, while several of the primitives are expandable.

We decided to denote this engine-level `x`-expansion by ending the
name part with `_x`, and to use `:n` as a signature.  There is a
precedent for such an `:n` signature for functions which perform some
expansion: `\int_eval:n` and most `int` functions, as well as `dim`,
`skip`, `fp`, etc.

The `\lua_now:x` function used to be a wrapper for `\directlua`, which
means that it was expandable and had a slightly different behaviour
than `\exp_args:Nx \lua_now:n` when `#` were involved.  This convinced
us that it was misnamed, so we changed the name to `\lua_now_x:n`
after checking on TeXLive that the function was unused (both Joseph
and I missed the lualatex-math code).  We also provided `\lua_now:x`
as a true `\exp_args:Nx` variant of `\lua_now:n`, hence it became
protected (non-expandable).  Since lualatex-math.sty relied on the
expandability (it had to), it unfortunately broke.

Kind regards,