Optimized TeX macros

TeX is a strange programing language, and it reflects in the manner in which TeX macros are optimized. I find the following macro from core-env.mki(i|v) really ammusing.

% handy for mp

\def\booleanmodevalue#1% can be \relax
   \fi\fi e}

So much effort to save two “e “


5 thoughts on “Optimized TeX macros

  1. I don’t think this is really an optimisation, just a cute example 🙂 The macros would be exactly the same if the “e” were inside the conditionals.

      • Oh sure, but I don’t consider that much of an optimisation — take a look at the source for \prg_replicate:nn in l3prg.dtx for an example of some more hairy optimised looping code 🙂 (And anything else, pretty much, written by David Kastrup.)

        • Oh, you didn’t catch the sarcasm in the title 🙂 I always marvel how much effort the TeX wizards put in to get the macro packages to work efficiently.

          • Heh, right, I see what you mean. In some cases, the TeX programming language can be great fun to work with in a puzzle-solving kind of sense.

            Keep up the writing, by the way. Good stuff.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s