4

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's length should always be 1.
-or-
within the callback, "char"'s length should always be 1.

Plural

chars 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 "chars", but I couldn't come up with a better example at the moment. The general idea still stands.

0

2 Answers 2

2

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.

chars

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 ... ... the resume() methods ...

... and so on.

4
  • To reference my example, you'll note that chars is a variable, so writing chars to mean the plural of char adds ambiguity that needs to be avoided.
    – zzzzBov
    Commented Jan 3, 2012 at 18:37
  • 1
    Or pick better variable names :D -- also (and this is getting a bit too programmer-y for EL&U) I would tend to write "char is defined in multiple scopes".
    – slim
    Commented Jan 3, 2012 at 18:41
  • Unfortunately, writing up a review of someone else's bad code doesn't lend itself to choosing variable names any more than pluralizing a quotation of someone else's word lends itself to changing the word.
    – zzzzBov
    Commented Jan 3, 2012 at 18:57
  • Then stick with char's - the slightly odd appearance is SO's fault not yours.
    – slim
    Commented Jan 3, 2012 at 19:03
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.

1
  • ...because not every situation can be easily rewritten in a different manner. Avoiding the issue is what I've done for over a year, at this point I'd like to address it and know the correct phrasing I should use.
    – zzzzBov
    Commented Jan 3, 2012 at 18:35

Not the answer you're looking for? Browse other questions tagged .