What's a good way to make a type a plural when writing comments?

When writing comments, I sometimes find myself needing to talk about a type (class, struct, etc.) in plural when writing comments, such as:

/*
 * getThings
 *    Get a list of --> Things <-- from somewhere.
 */
Thing *getThings(void);

The problem is, the type name is singular (namely, Thing ), but I want to talk about them in plural in comments.

If I say Things , it suggests to the reader it's talking about a type called Things , which is not the case. If I say Thing's , it looks awkward because it's not grammatically correct (it's either possessive or "Thing is", not plural). I could talk around the problem and say a list of Thing items

What's a good convention to stick to when writing plurals of types?


Well, depending on the documentation system you're using, you can wrap the name of the type in a special syntax and put the s outside it. For example:

.NET XML comments

Get a list of <see cref="Thing"/>s from somewhere.

doxygen C/C++ comments

Get a list of link Thing endlink s from somewhere.

Not 100% certain on the doxygen variant but it should be something like that.

And if you're not using a particular documentation system and thus have no special comments, I'd do something like:

Get a list of [Thing]s from somewhere.

Or you could use ( ) or { }, depending on preference...


我会在括号中使用's'。

/* Get a list of Thing(s) from somewhere */
链接地址: http://www.djcxy.com/p/2446.html

上一篇: 如何释放与Git?

下一篇: 在撰写评论时,将某种类型变为复数形式的好方法是什么?