6

What expl3 functionality, if any, will break if I redefine the space character to have catcode 10?

\ExplSyntaxOn
    \char_set_catcode_space:n {32}
    ...
    % Does everything work as before?
    ...
\ExplSyntaxOff
Evan Aad
  • 11,066
  • 1
    it depends what you mean by "break" lots of examples that you copy from elsewhere will of course be written assuming normal expl3 conventions, but the workings of each command are not affected – David Carlisle Oct 10 '17 at 15:35
  • 2
    No functionality is broken, but of course you need to take care of unwanted spaces. In kantlipsum I use \char_set_catcode_space:n {`\ } when the Kantian paragraphs are defined; changing spaces and newlines to ~ would be cumbersome. – egreg Oct 10 '17 at 15:37
  • @DavidCarlisle: So the functions of expl3 will work the same? How about xparse? – Evan Aad Oct 10 '17 at 15:38
  • @egreg: What about formatting? Will I still be able to format the code freely? For instance adding whitspace between the arguments to a function, or placing the arguments on successive lines? – Evan Aad Oct 10 '17 at 15:40
  • 1
    @EvanAad You can't have \cs_new:Npn \ea_foo:nn #1 #2 {...}, for instance, because spaces would be significant. That's an instance of what “take care of unwanted space” referred to. – egreg Oct 10 '17 at 15:45
  • 3
    no tex macro whatever package it is defined in, expl3, xparse, longtable,... is affected by the catcodes in the document once it is called, the catcodes in the document just affect how the characters in the document file are tokenized, so arguments may be tokenized differently and therefore produce a different result but the macro itself just depends on teh tokens it is passed, not the catcodes in the file (unless of course it tests the current catcode values explictly with \ifnum\catcode32=10 yes\else no\fi – David Carlisle Oct 10 '17 at 15:57
  • 1
    @EvanAad The entire reason for make spaces ignored in code blocks is to allow free formatting: one of the longest-standing ideas in expl3 (might even predate David's involvement!) – Joseph Wright Oct 10 '17 at 16:15
  • @JosephWright it does predate my involvement so before 1992 I think. – David Carlisle Oct 10 '17 at 16:27

1 Answers1

11

Things will tend to go silently wrong with little warning. The functions themselves are of course unaffected by the catcodes in the document but the spaces in the document are interpreted differently so code fragments expecting the normal context will break.

Gives me an excuse to break some of egreg's code. Suppose you had copied some code from

https://tex.stackexchange.com/a/24067

\documentclass{article}
\usepackage{expl3}
\begin{document}


\ExplSyntaxOn
%\catcode`\ =10\relax
  \cs_new:Npn \exampleone:nn #1 #2 {[#1 #2]}
  \cs_new:Nn \exampletwo:nn{#1 #2}

\texttt{\cs_meaning:N \exampleone:nn}\par

\texttt{\cs_meaning:N \exampletwo:nn}\par

\exampleone:nn{aa}{bb} cc dd

\ExplSyntaxOff


\end{document}

Produces

[aabb]ccdd

which is the intended result here.

If you uncomment the catcode setting then you get

[aabb cc]dd

which may or may not be what you expect, depending what your expectations are.

David Carlisle
  • 757,742