[personal profile] dmaze
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).


% 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.

Date: 2007-02-18 06:33 pm (UTC)
From: [identity profile] fredrickegerman.livejournal.com
Mostly I just chalk this up as another example of "Donald Knuth is very smart, but can't design a decent programming language."

Profile

dmaze

Expand Cut Tags

No cut tags
Page generated Jun. 7th, 2025 09:30 pm
Powered by Dreamwidth Studios