Take the 2-minute tour ×
English Language & Usage Stack Exchange is a question and answer site for linguists, etymologists, and serious English language enthusiasts. It's 100% free, no registration required.

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.

share|improve this question

marked as duplicate by MετάEd, RegDwigнt Jan 14 '13 at 9:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

2 Answers

up vote 2 down vote accepted

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.

share|improve this answer
    
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 Jan 3 '12 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 Jan 3 '12 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 Jan 3 '12 at 18:57
    
Then stick with char's - the slightly odd appearance is SO's fault not yours. –  slim Jan 3 '12 at 19:03
add comment

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...


EDIT: Added 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.

share|improve this answer
    
...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 Jan 3 '12 at 18:35
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.