Plurals and possessives of quoted words [duplicate]
Possible Duplicate:
Marking plural of code words
Pluralizing Keywords in Programming Languages
After asking a number of questions on StackOverflow, I keep running into some of the same phrasing issues. Typically these issues stem from variable names.
How do I correctly pluralize or possessivize* a word or phrase in quotes or code blocks?
Are there any differences in grammatical structure if <code>
blocks, or `
characters are used to delineate quoted words, phrases, or variables instead?
* I don't know the right word for "possessivize" either; anyone who would like to correct it can be my guest
As a simple example that involves some basic JavaScript code:
var chars, char;
chars = 'abcdefghijklmnopqrstuvwxyz'.split('');
chars.forEach(function (char, index, chars) {
console.log(index, char, char.length);
});
console.log(char);
Possessive
within the callback,
char
'slength
should always be1
.
-or-
within the callback, "char"'slength
should always be1
.
Plural
char
s are defined in multiple scopes
-or-
"char"s are defined in multiple scopes
I'm aware that these aren't the best of examples, as I would typically write "char
instances" instead of "char
s", but I couldn't come up with a better example at the moment. The general idea still stands.
Solution 1:
The answer to any question on written English is to get a representative sample of the existing corpus of literature, and go by that example. Writing about computer programming is no different.
Computer books do not tend to use quotes to indicate variable names or types. They tend to define a font for the purpose and use it throughout the book. Most programming books take a few pages to describe their typographical conventions, because they are not universal.
My instinct when pluralising char
or stating it in the possessive would be to use the 'variable' font for the name of the variable, and an 's' or apostrophe-s in the body text font.
char
s
char
's
Unfortunately, StackExchange's markup puts an unwanted space in here. Because of that technical issue, it seems like an acceptable compromise to put the whole word in the 'variable' font:
chars
char's
I can think of few occasions in "normal" English usage where this is an issue, although it's not difficult to come up with a contrived example.
He often described his trumpet as his "hooter".
(then later)
His "hooter"'s cone was dented.
These occasions must be so rare, that rewording to avoid the problem is probably not too much to ask:
The cone of his "hooter" was dented.
Or, without losing the meaning:
His "hooter's" cone was dented
I picked Java In A Nutshell off the bookshelf, as a sample, and in a skim-read, didn't find a single instance of a differently-typefaced word being pluralised or used in the possessive. My guess is that this is an editorial decision. It is always worded to avoid the issue:
... the
Runnable
objects ... ... theresume()
methods ...
... and so on.
Solution 2:
Why not reword to avoid confusion?
...within the callback, the length of
char
should always be 1.
and, as you suggested,
...
char
instances are defined in multiple scopes...
Here are some style guide references to support my answer.
Yahoo style manual recommends re-wording, as does reference.com, and The manual of scientific style: a guide for authors, editors, and researchers By Harold Rabinowitz section 3.6.7.ii-iii
On the other hand, the Chicago Manual of Style says
The plural of a word or phrase in quotation marks is now formed without anapostrophe—that is, with the addition of s or es within the quotation marks. Note the example: “To be continueds”
Although it does not address possessives of items in quotes.