summaryrefslogtreecommitdiff
path: root/info/challenges/aro-bend/exercise.008
blob: e64505a8ff4586ec955cc6d7db7651a9e3d7e0db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Date: 21 Jun 1993 09:49:27 -0400 (EDT)
From: Michael Downes <MJD@MATH.AMS.ORG>
Subject: Around the Bend #8
To: info-tex@shsu.edu

A few readers of info-tex and comp.text.tex may recall some postings
of mine under the name of `Around the Bend' more than a year ago. This
was intended to be a regular quasi-monthly stream of challenging
questions about TeX macro writing, but after a few appearances it fell
into limbo because of too many other demands on my time.  However I
continue to encounter hard, interesting problems in my work so
herewith wish to announce resumption of the `Around the Bend' postings
on an occasional, slightly less ambitious basis.

For background, here are a couple of excerpts from the first `Around
the Bend' post:

> With the encouragement of George Greenwade (the INFO-TeX list owner), I
> would like to propose a regular department for INFO-TeX, called `Around
> the bend'. It will consist of macro-writing challenges on the level of
> the dangerous-bend exercises in the TeXbook, with interested parties
> invited to collaborate and/or compete to find the best solution. My
> motivation for doing this is partly selfish: to get more feedback from
> other macro writers about some of the interesting macro-writing
> problems that I run into.
> 
...
> Solutions should be sent to me instead of to INFO-TeX or
> comp.text.tex, on the premise that people usually won't want to read
> others' solutions until they've had a chance to try their own hand. A
> summary of the results would then be posted to the INFO-TeX list after
> two or three weeks; to those who submit solutions before the deadline,
> I could forward without delay solutions submitted by other people, for
> comparison.

And here's number 8.

***********************************************************************
*** Exercise 8 (hard):
Under certain conditions, TeX fails to give an error message
for a missing closing brace or \endgroup or \fi; it only gives an
unobtrusive warning message after the end of the TeX run, which is
easy to overlook:

  (\end occurred inside a group at level 1)
  (\end occurred when \iffalse on line 6 was incomplete)
  (\end occurred when \iftrue on line 3 was incomplete)

Is there any way to trap these conditions and give a true error
message?---if, let's say, you are programming for a major macro
package like LaTeX and want to make sure these conditions are brought
to the user's attention.

***********************************************************************

Remark: Off-hand one would think that trapping these conditions is
impossible, since otherwise Knuth would presumably have built the
trapping into TeX; \iffalse ... \end generates an error message, it's
only \iffalse ... \else ... \end or \iftrue ...  \end that leave TeX
mumbling instead of shrieking. But in some cursory experiments, I
found a not-too-bad solution for the missing end of group condition.
I'd be pleased to see someone else come up with a better solution,
however, as well as a solution to the missing \fi problem.

Send answers to:

Michael Downes      mjd@math.ams.org (Internet)

A summary will be posted circa July 12, 1993.