Sex, pluralism, and TableMaster

If you were expecting something either salacious or political here, sorry, it’s just about system variables and output formatting codes. I’ve spent the past few days adding more output formatting codes in order to get them into the manual before it goes to the printers. While I was at it, I added a new sort of system variable, too, to help with pronouns.

I’ll start with the system variable. As I described in yesterday’s blog post, you can use subtables to get around the lack of an output formatting code to make something plural. That’s far from the only thing you can use that system for, of course. In many cases, I’ve been setting a user variable called {Sex} and then using embedded subtable calls like [They] and [Them] to get “he”, “she”, etc., as needed.

There’s a saying in programming that if you find yourself doing the same thing repeatedly, you should write a subroutine for it. Well, if you’re the person who wrote the programming language and you find yourself writing the same subroutine over and over again, you should add a language feature for it! I’ve been doing as described for the pronouns for a long time, too long, really, so I decided I’d better set up a language feature for it.

So, we now have the system variable {$Sex} and the related system variables {$They}, {$Them}, {$Their}, and {$Theirs}. The only one the user should generally change is {$Sex} — set it to 0 for neuter, 1 for male, or 2 for female. When you do that, the other four are set accordingly, so you can just use {$Their} in a print line, for instance, and get its, his, or her as appropriate to whatever you set {$Sex} to. At the moment a {$Sex} of 3, or actually anything except 0-2, will produce an actual they, them, their, or theirs, but this is an unsupported feature and may change or disappear without notice.

{$They}, etc., are not protected from user changes like {$Pi} is, so you can change them around yourself for special effects if you want, but that isn’t recommended.

I’m considering extending this further in a later release, perhaps to allow for easy switching to plural pronouns as well. That partly depends on how useful, and how popular, the feature actually turns out to be.

So that’s the sex part. What about the pluralism?

Well, technically, it’s actually pluralization, but I’ve been reading so much political news lately that I couldn’t resist using that title. And in this case, it’s another new output formatting code to handle plurals: \x.

One of the more problematic plurals has been words that end in ‘x’ like ‘vortex’ and ‘helix’. They’re not all that commonly used in TableMaster tables (I don’t think!) but there are a number of them, so they really should have a built-in plural, and as it happens one of the last remaining letters for output formatting codes was ‘x’. The problem with them, of course, is that ‘vortex’ or ‘index’ end with -ex and ‘helix’ ends with -ix, but they both use -ices for their plural. So the new \x output formatting code trims off the last letter from the word (whether it’s i or e) and adds ices.

So one vortex, two vortices; one helix, two helices.

Of course, you can just use the \s construction; it’s becoming more common, and I certainly won’t argue against irregular plurals being regularized! But if you want to be grammatically correct and talk about vortices instead of vortexes, use \x instead of \s.

Speaking of being grammatically correct, it wasn’t all that long ago that I discovered that the correct plural for octopus isn’t octopi, it’s arguably octopodes. It all goes back to the Latin, and I don’t pretend to understand declensions of nouns, especially nouns from Greek roots, and even further those that didn’t actually exist until Linnaeus started messing with them. But there’s fairly solid reasoning behind the idea that an octopus and another octopus are two octopodes, and a platypus and another platypus are two platypodes. So, if you really want to confuse everyone around you who’s never heard of octopodes, you can use \p: octo\p or playt\p to be precise. It’s probably a waste of a letter for an output formatting code, but it was just bothering me.

There are also a few new codes that don’t make plurals. One of them makes entire variables upper- or lower-case. That’s \k and \K, and it’s used like this:

.print The orc yells "TAKE \K{Their} STUFF!"

Depending on the value of {$Sex}, that would produce the appropriate one of the following:

The orc yells "TAKE ITS STUFF!"
The orc yells "TAKE HIS STUFF!"
The orc yells "TAKE HER STUFF!"
The orc yells "TAKE THEIR STUFF!"

That’s something else that’s probably going to be expanded in a future release; there should be an option for capitalizing just the first letters of a text variable, and maybe it should work for embedded subtable calls, too. That’s really a last-minute addition to 1.0.5, so any further expansion (and the possibility of a .DEFAULT option as well) has to be postponed to 1.1.0 or later.

In addition to variables, \K will also work on dice rolls. What’s the point of capitalizing a number? Well, that’s where two more new formatting codes come in: \# and \@. What they do is turn the result of a dice roll or a variable (integer only, not decimal or or course text) into a word if it is a single digit. There are, by the way, several opinions on when to use words and when to use numerals, but I’m going with the version in the Chicago Manual of Style section 9.3, which isn’t their preferred version, in fact, but nonetheless I think works best for table use. The difference between \# and \@ is that \# spells out all the numbers from zero through nine, while with \@, 0 produces ‘no’ and 1 produces ‘a’. \K and \C can be used with either one.

So this line…

You see \@<1d6> orc\s.

…would produce output like:

You see no orcs.
You see an orc.
You see two orcs.

Of course, \@ and \a handle a/an correctly, just like a\n would.

Here’s a complete list of all the (current) output formatting codes. Theoretically this is the final list; I’m going back to finishing up the manual editing (and putting in these new codes!) after I finish with this blog post and adding some more about the subroutines to yesterday’s.

Update: \f is now smarter, and understands \fe as needing to keep the ‘e’ when singular, drop it when adding ‘ves’. This is the last change, really; I’m finishing up that section of the manual now!

\\    real backslash
\+    real plus (beginning or end of line)
\-    real minus (end of line)
\(    real parenthesis
\<    real angle bracket
\[    real square bracket
\{    real squiggly bracket
\2..9 pad number that long with spaces
\,    comma and space if more rolls to go
\_    space if not a prior space
\;    comma and space if not a prior space
\'    singular/plural possessive
\#    text numbers one through nine
\@    text numbers, alternate 0 and 1

\a    A/nothing (A box / boxes)
\b    antenna/antennaE
\c    lowercase next letter
\C    capitalize next letter
\d    child/childREN
\e    mAn/mEn
\h    hero/heroES
\f    elF/elVES, kniFe/kniVES
\g    polyhedrON/polyhedrA
\i    cactUS/cactI
\j    crisUS/crisES
\k    lowercases next dice roll or variable
\K    uppercases next dice roll or variable
\l    peRSON/peOPLE
\m    parameciUM/parameciA
\n    hanging N
\o    fOOt/fEEt
\p    octoPUS/octoPODES
\q     wAS/wERE
\r    IS/ARE
\s    book/bookS
\t    1st/2nd/3rd/4th
\u    mOUSe/mICe
\v    haS/haVE
\x    indEX/helIX--> indICES/helICES
\y    partY/partIES
\z    reverse of 's'

So, depending on how you count them — whether escaped characters like \< and \+ really count as codes, whether \c and \C count as one or two, and whether \2 through \9 count as one or 8, there are anywhere from 32 to 48 of the things. You could even make a case for 71 if you count all the upper and lower-case versions of the codes separately.  No matter how you count them, though, there are an awful lot of output formatting codes now; in its final form the original TableMaster has only 11, or 13 if you count the escaped characters. And, if I remember correctly, the very first version had about five.

Output formatting codes are one of the strengths of TableMaster. They let you produce output that looks like a person wrote it instead of a script: “You see three orcs” instead of “You see 3 orc.” They will really enhance your table output. Go ahead and use all 32 (or 48, or 71) of them!

Note: Yes, some of them do look a bit weird. \b, \h, \g, \j, and \q in particular have nothing in common with the results they produce. It was a matter of not having available letters that did make sense in those contexts because they’d been used for other codes already. There’s really no alternative other than going to 2-letter codes, which would just look awkward and, in most of those cases, not a whole lot better anyway.