[fpc-pascal] distinct types and type identifier

Graeme Geldenhuys graemeg.lists at gmail.com
Wed Jan 30 10:30:55 CET 2008


Hi,

Below is from the Kylix 3 help.

--------------------------[ copy ]------------------------------
Type identity is almost straightforward. When one type identifier is
declared using another type identifier, without qualification, they
denote the same type. Thus, given the declarations
type
  T1 = Integer;
  T2 = T1;
  T3 = Integer;
  T4 = T2;

T1, T2, T3, T4, and Integer all denote the same type. To create
distinct types, repeat the word type in the declaration. For example,
type TMyInteger = type Integer;creates a new type called TMyInteger
which is not identical to Integer.
--------------------------[ end ]------------------------------

So when am I supposed to use

type
  TfpgColor = longword;

vs

type
  TfpgColor = type longword;

???
What's the actual difference between them?  I have used the first
option (declaration) in the fpGUI project. For things like:

const
  clBlue = TfpgColor($0000FF);


Is the above the same as what the Free Pascal documentation describes
below?  Or is this something different?

--------------------------[ copy ]------------------------------
The last class, type identifier, is just a means to give another name
to a type. This presents a way to make types platform independent, by
only using these types, and then defining these types for each
platform individually. The programmer that uses these units doesn't
have to worry about type size and so on.
--------------------------[ end ]------------------------------


Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-pascal mailing list