Article View: comp.text.tex
Article #10123Re: (Another) puzzler for wannabe wizards
From: Alan Jeffrey
Date: Thu, 06 Jun 1991 09:14
Date: Thu, 06 Jun 1991 09:14
38 lines
1957 bytes
1957 bytes
In article <RAICHLE.91Jun5125624@azu.informatik.uni-stuttgart.de>
Bernd Raichle <raichle@informatik.uni-stuttgart.de> posed a horrible
catcoding problem...
> \catcode`\"=\active\gdef"{\"}
> T"ater % output: T\"ater
> \begingroup\catcode`\"=12
> \showthe\catcode`\" % print: 12
> % @<Insert your hack at this place@>
> \showthe\catcode`\" % print: 12
> T"ater % output: T''ater
> \catcode`\"=\active
> T"ater % output: T''ater
> \endgroup
> T"ater % output: T\"ater
> \bye
> At the place marked with @<Insert your hack...@> there should be a
> local(!) re-definition of the active char "
Well, here's my solution---the only cheat is that it uses an extra
auxilary definition, to swap the order of evaluation (I can't see any way
to do this without something similar, as you need to give TeX's stomach
the tokens "_13 then "_12 despite having read them in the
order "_12 then "_13):
\def\Swap#1#2{#2{#1}}
And the contents of the gold envelope:
\expandafter\Swap\expandafter{\the\catcode`\"\def#1{"}}
{\catcode`\"\active\Swap}{\def"#1}\catcode`\"""
Anyone got a solution that doesn't use \Swap or something similar?
Alan.
Alan Jeffrey Tel: +46 31 72 10 98 jeffrey@cs.chalmers.se
Department of Computer Sciences, Chalmers University, Gothenburg, Sweden
Technical Details
Message-ID:
<4651@undis.cs.chalmers.se>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!uupsi!sunic!chalmers.se!cs.chalmers.se!jeffreyReferences:
<RAICHLE.91Jun5125624@azu.informatik.uni-stuttgart.de>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!uupsi!sunic!chalmers.se!cs.chalmers.se!jeffrey From: jeffrey@cs.chalmers.se (Alan Jeffrey) Newsgroups: comp.text.tex Subject: Re: (Another) puzzler for wannabe wizards Keywords: Dirty Tricks, catcode changing, puzzle Message-ID: <4651@undis.cs.chalmers.se> Date: 6 Jun 91 09:14:43 GMT References: <RAICHLE.91Jun5125624@azu.informatik.uni-stuttgart.de> Sender: news@cs.chalmers.se Distribution: comp Organization: Dept. of CS, Chalmers, Sweden Lines: 38