[texhax] Defining a command which runs differently based ion input argument

Reinhard Kotucha reinhard.kotucha at web.de
Thu Dec 30 02:39:15 CET 2010


On 29 December 2010 Uwe Lueck wrote:

 > Less seriously, with *ternary* computers, we might have 
 > 27 category codes instead of only 16 ...

Actually, 3^4=81.

But I don't think that we need more category codes.  The sole purpose
of them is to assign different meanings to one and the same character,
which is not desirable at all.

In this particular case, the problem is that curly braces are
ambiguous.  The only _reasonable_ solution is to provide two macros
with distinct, meaningful, names.  This makes the file more readable
to humans and allows other programs to parse the file.

Additional catcodes are not helpful.  You need them in order to
distinguish between

  \foo{optional argument}

and

  \foo{\large ordinary text}

But how should, for instance a text editor, distinguish between the
different meanings of curly braces in order to provide proper syntax
highlighting, if each occurrence of "{" has a different meaning?

Please note that I regard LaTeX more as a markup language rather than
a programming language.  LaTeX has a clear syntax, optional arguments
are in box brackets, not in curly braces.  I don't see any good reason
to break LaTeX's syntax rules deliberately.

I don't know whether DEK is still convinced that the invention of
catcodes was a good idea.  He avoided them in Metafont, at least.

Regards,
  Reinhard

-- 
----------------------------------------------------------------------------
Reinhard Kotucha                                      Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover                              mailto:reinhard.kotucha at web.de
----------------------------------------------------------------------------
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
----------------------------------------------------------------------------


More information about the texhax mailing list