It seems to me that it is grammatical to write
- The variable x is an integer.
or
- The variable x is of integer type.
But what about
- The variable x is of type integer.
?
It does not sound incorrect to me.
It seems to me that it is grammatical to write
- The variable x is an integer.
or
- The variable x is of integer type.
But what about
- The variable x is of type integer.
?
It does not sound incorrect to me.
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.
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 09:29
$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
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".
myParam : string. Which still doesn't quite match type: integer. In OP's phrase, "type" is used semantically (in English), not declaratively (as a programming language), so I agree that the colon makes no sense in this context.
– Flater
Feb 22 '18 at 09:33
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.
– user
Feb 22 '18 at 13:30
integeris 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