Parsing -- gotta love it
Feb. 16th, 2007 10:22 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
In knee-jerk reaction to something that appeared on comp.compilers, I figured I'd go off and write a TeX file that defined, and invoked, a macro named \{} (that is, the name of the macro is \{}, not empty).
This has all kinds of terrible implications. Mostly they're only exploited by the LaTeX \makeatletter and \makeatother macros to "hide" things from non-package code. But nothing actually stops you from creating a macro named \$; if I understand the implications of \active, nothing stops you from creating a macro named just $ either and thereby confusing everybody who expects math mode.
% create a strangely-named macro \expandafter\def\csname {}\endcsname{foo} % invoke it \catcode`\{=11 \catcode`\}=11 \{} % switch back to sanity and quit \catcode`\{=1 \catcode`\}=2 \bye
This has all kinds of terrible implications. Mostly they're only exploited by the LaTeX \makeatletter and \makeatother macros to "hide" things from non-package code. But nothing actually stops you from creating a macro named \$; if I understand the implications of \active, nothing stops you from creating a macro named just $ either and thereby confusing everybody who expects math mode.
no subject
Date: 2007-02-18 06:33 pm (UTC)no subject
Date: 2007-02-19 05:42 am (UTC)