Thanks Marco, interesting history lesson. ;-) On 2016-03-29 22:16, Marco van de Voort wrote: > Moreover since shorter types are not always faster, I think it is better to > forget all this, and in new code use INTEGER for the variable types, where > range doesn't matter (much) and (u)int<xx> for the rest.
I already tend to use Integer for most code, but the code I'm currently working on has an extensive amount of record structures used to read a complex binary data file. The documentation for the data file is primarily in C and uses types like SHORT, USHORT, LONG etc. These translated easily to the SmallInt, Word, LongWord etc types, but as already mentioned in can get confusing keeping track of valid ranges and occasional programmer error. So I definitely see the benefit in using (U)Int<xx> style data types. They are a lot more obvious [to the programmer] regarding data ranges and byte size. I was just surprised not to find any reference to them in the FPC documentation. I already made personal annotations about them so as not to be forgotten, but I think it will be beneficial to have them officially included in the FPC Language Reference too. After all, they are part of the System unit. Here is an example of the annotation I added to my own documentation. Type Range Size in bytes ──────────────────────────────────────────────────────────────────── Int8 = ShortInt -128 .. 127 1 Int16 = SmallInt -32768 .. 32767 2 Int32 = LongInt -2147483648 .. 2147483647 4 Int64 -9223372036854775808 .. 9223372036854775807 8 UInt8 = Byte 0 .. 255 1 UInt16 = Word 0 .. 65535 2 UInt32 = Cardinal 0 .. 4294967295 4 UInt64 = QWord 0 .. 18446744073709551615 8 ──────────────────────────────────────────────────────────────────── Regards, - Graeme - _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal