[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."

Date: 2007-02-19 05:42 am (UTC)
From: [identity profile] iabervon.livejournal.com
I was just thinking of this sort of thing, because I listened to this week's Wait Wait Don't Tell Me, and the first listener contestant, while chatting before playing, said "Gotta love it."
Page generated May. 29th, 2025 02:36 pm
Powered by Dreamwidth Studios