[fpc-devel] integer, cardinal

Nikolay Nikolov nickysn at SexMagnet.com
Sun Apr 17 14:18:14 CEST 2005


Ales Katona wrote:

> I think that pascal typesystem requires a bit overhaul when it comes 
> to integers.
>
> First of all Integer should be size independent, that is, xy bits 
> depending on the platform. All others should be specific.
>
> Second, we should "force people in a friendly way" to use more 
> readible names like:
> sint32, uint64, etc. than "cardinal"
> In a few years when 64 bits are normal, what will cardinal become? who 
> knows..
>
> just one big IMHO
>
> Ales

I like the way it is:

unsigned integers:
byte (8-bit)
word (16-bit)
dword (32-bit)
qword (64-bit)

and signed:
shortint (8-bit)
smallint (16-bit)
longint (32-bit)
int64 (64-bit)

The unsigned versions have either 'byte' or 'word' in their name, and 
the signed have 'int'. (I prefer to use 'dword' instead of 'cardinal') 
Even on 64-bit systems always using 64-bit integers is a waste of 
memory. The problem with the 16-bit int was that the range 
-32768..+32767 was too small, and people often needed to use 32-bit, 
even though it was slower. Nowadays numbers outside the range of longint 
are rarely needed, and when needed, one can always use int64/qword or 
even redefine integer to be 64-bit :)

Also using mode <> objfpc and delphi should be only for compatibility 
reasons. The overhead in using mode objfpc is almost nil. (only unit 
objfpc is included, and it is rather small) Now if you add uses sysutils 
or classes, then the program gets larger, but that has nothing to do 
with mode objfpc.




More information about the fpc-devel mailing list