5

I ask about some of the best practices for programming expl3 code.

Section 4 of interface3.pdf describes functions that define new control sequences that prohibit \par in their function parameters (#1, #2, etc.). These functions have _nopar in their name (e.g. \cs_new_nopar:Npn, \cs_new_protected_nopar:Npn, \cs_new_nopar:Nn, etc.)

My question is: When should the programmer instead use the nopar alternatives when defining new functions in LaTeX3?

A related question has been discussed here (Why don't we always use \long\def instead of \def?), but I would like an answer that is more related to expl3.

1 Answer 1

7

The team generally use nopar in very limited circumstances

  • For low-level implementation of variables, in particular tl, which are 'short' macros behind-the-scenes
  • For implementation of ltcmd, which differentiates 'long' and 'short' arguments at a document level

Beyond that, almost all of the team's code is 'long'. The reason is that there is no performance advantage to 'short' macros. At the same time, \par tokens can pop up in many programming contexts, and the 'error handling' aspect of 'short' macros is only really useful at the document level (as already noted).


Perhaps of interest is that in LuaTeX there is \suppresslongerror, which can turn off the error entirely, and that's the approach taken in ConTeXt.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .