3 ms·
> I lost track of this discussion! Hah, me too. I wonder if you will ever see this :-) > Few people write code for PCs with the assumption that an int could
by TheNewAndy 10y ago
> I lost track of this discussion!
Hah, me too. I wonder if you will ever see this :-)
> Few people write code for PCs with the assumption that an int could be 16-bits wide. They all assume that it's going to be 32-bits at least. A generic "int" encourages bad assumptions.
If people are just writing code for PCs, then it is no longer portable code that is being talked about.
But when writing portable code, which you do and I do, being overly specific with type widths is bad.
The C data types all have very specific widths, and it is just a fact that int is at least 16-bits wide.
I'm not a swift person either, but based on reading this:
https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html https://developer.apple.com/library/content/documentation/Sw...
It sounds like the types with numbers in their name are most certainly fixed width types. The original commenter didn't like the emphasis on such fixed widths, and I think the swift language designers agree - their section on the "Int" type (which is at least 32-bits wide, but may be 64-bits wide) says that this is the type that people should be using generally.
"Int" in swift is quite similar to "int" in C, just the C version is less constrained (may be any width >= 16 bits). But the principle is the same - for better portable code, enforcing exact widths of types is not a good thing.