9

It seems to me that it is grammatical to write

  1. The variable x is an integer.

or

  1. The variable x is of integer type.

But what about

  1. The variable x is of type integer.

?

It does not sound incorrect to me.

  • 2
    I think in example 3, you'd want to put single quotes around 'integer', or set it off with italics. I would do the same with example 2, though it doesn't feel as necessary there. #3 is a very common usage among scripters/programmers, but usually with integer set off typographically. – spoko Feb 21 '18 at 23:36
  • @spoko -- integer is often set off typographically by putting it in a fixed-width font. (Many tools for editing programming source code use fixed-width fonts.) Many web sites (including most StackExchange sites) use fixed-width fonts to identify text that is included in programming source code verbatim. – Jasper Feb 21 '18 at 23:56
  • 2
    There is an underlying rule here that has to do with with types generally. We see similar phenomena in biological classification, for example. – Tᴚoɯɐuo Feb 21 '18 at 23:58
  • @spoko: I agree that it's common among programmers, but almost always, it will use the keyword (int) rather than the full English name (integer). Depending on OP's programming language, integer may actually be the keyword. – Flater Feb 22 '18 at 9:27
35

Neither of the sentences is incorrect, but they have slightly different meanings in technical context.

The variable x is of type integer.

This sentence indicates that the variable is specifically of type integer - that is, the type name in the language is exactly that. Usually it'll refer to either a 32- or 64-bit wide integer type depending on the platform. Also I agree with @spoko in the comments that integer will usually be typeset to distinguish it from the rest of the sentence, or put in quotes.

The variable x is of integer type.

This sentence, however, indicates that the variable type is of some integer (as in, capable only of holding whole numbers) type. This might be int/integer, but it could also be a byte, short, or whatever type your language defines.

The variable x is an integer.

This sentence is somewhat more general - if we understand "the variable" as referring to its value (a common, if not always correct, technical shorthand), it might mean that the variable is of an integer type, or that it's of a fractional type that happens to hold an integer at the moment.

  • 1
    The third sentence (in your answer, not OP's question) could also occur in mathematics, while the first two are pretty exclusively computer science jargon (mathematics doesn't tend to talk about "types" nearly as much as computer science does). – Kevin Feb 22 '18 at 3:43
  • 5
    or that it's of a fractional type that happens to hold an integer at the moment Slightly disagree here. The phrase is "The variable x is an integer.", thus referring to the variable, not the value contained within. If the phrase were "The value of (the variable) x is an integer.", I'd be more inclined to agree. – Flater Feb 22 '18 at 9:29
  • The 3rd sentence is usable in math, but considered very vague in CS. Think of weakly typed languages, like PHP. You can assign a string $s = '3'; of course, it can be correctly used in numerical comparsions, because it is an integer, although var_dump outputs it as string. – rexkogitans Feb 22 '18 at 11:00
  • 2
    @Kevin There is an entire branch of mathematics (type theory) devoted to assigning types to values (primarily to avoid various paradoxes in set theory). This doesn't invalidate your observation that types aren't common in most branches of mathematics, though. :) – chepner Feb 22 '18 at 15:17
-1

This is mostly a convention in technical writing. I expect there should be a colon between "type" and "integer" to explicitly show that this is a name/value pairing, but most writers will leave it out.

If you declare the variable to be of type: integer you have to be careful of buffer overflow.

You will find many such artifacts in this kind of writing. Technical writers like short, choppy sentences focused on facts and with little "decoration".

  • 16
    I have been working in computer science and software engineering for decades, and that colon makes no sense to me. – David K Feb 22 '18 at 4:36
  • 5
    Can you give an example of a technical manual that uses a colon in that way? – David K Feb 22 '18 at 8:34
  • 4
    @Flater Pascal uses that notation too (function Foo(bar: Integer): Integer or var baz: Integer), and might have borrowed it from earlier languages. In more modern terms, UML uses that notation as well. The type declaration notation name: type certainly dates much farther back than Typescript. However, I don't think I've ever seen it used to emphasize a name/value pair in ordinary running prose, as Andrew seems to suggest. – a CVn Feb 22 '18 at 13:30
  • 2
    To be honest, if I were editing such a document, I would remove such a colon as being more harmful than helpful. It might work if you have it within code formatting, but even then it would appear (to me) as more than a little hammy — ultimately all you've done there is add decoration. Why not use the common and varyingly-accurate expressions described by Maciej? – Lightness Races in Orbit Feb 22 '18 at 14:21
  • 4
    @MichaelKjörling Yeah, that's a syntactic construct found in programming languages, not something you would see in English. – chepner Feb 22 '18 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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