home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.text.tex
- Path: sparky!uunet!ukma!gatech!udel!sbcs.sunysb.edu!hanche
- From: hanche@ams.sunysb.edu (Harald Hanche-Olsen)
- Subject: Re: Problems with false conditionals
- In-Reply-To: Donald Arseneau's message of Tue, 26 Jan 1993 02: 20 PDT
- Message-ID: <HANCHE.93Jan27163157@ptolemy.ams.sunysb.edu>
- Sender: usenet@sbcs.sunysb.edu (Usenet poster)
- Nntp-Posting-Host: ptolemy.ams.sunysb.edu
- Organization: University at Stony Brook, NY
- References: <10348853@MVB.SAIC.COM>
- Date: Wed, 27 Jan 1993 21:31:57 GMT
- Lines: 21
-
- The question of how to write if tests so they nest properly is one
- which leads people with short memories (like me) into trouble every
- time. So I thought about it for a while, and came up with the
- following test building macro (for people who favour the \if\test style):
-
- \def\maketest#1#{\m@ketest{#1}}
- \def\m@ketest#1#2{\def#1{..\fi#2}}
-
- For example, here is how you can use it to define a macro to test
- whether a control sequence has a given expansion:
-
- \maketest\expands #1->#2{{\def\temp{#2}\expandafter}\ifx#1\temp}
-
- Example: The following prints "Good." on the console.
- \def\foo{bar} \if\expands \foo->{bar}\message{Good.}\fi
-
- You can even put \global or \long in front of \maketest, and it will
- do what is expected. But if a \maketest invocation ever occurs in
- text that might be skipped, you'll still have to, you'll still have to
- put a \ifx\fi\relax\fi after it, because a \maketest usage by its
- nature must always contain an unbalanced \ifsomething.
-