> On 30/01/2008, ik <[EMAIL PROTECTED]> wrote:
>> type
>>   TfpgColor = type longword;
>>
>> means that you have a new type in the same *range* of longword. That
>> means that you can assign the same number range, but if you have a
>> variable that is a longword, and you wish to assigned the value to a
>> TfpgColor, then you must cast it, or the compiler will tell you that
>> it expect a TfpgColor content (unless there is a bug ;)).
>
>
> Ah, okay. Now why can't they explain it like you just did, but in the
> help. :) Where could I add this explanation in the FPC docs?
>
> I think I'll use the type as define above from now onwards... That way
> we should always know what we are working with (TfpcColor in this
> case) when assigning values to variables etc.

In case of unique integer types. The types are not the equivalent, but are 
still compatible and
will be converted implicitly by the compiler. It unique types affect procedure 
overloading. The
following short example demonstrates this.

type
  TfpgColor = type longword;

procedure f(c:TfpgColor);
begin
end;

procedure f(l:longword);
begin
end;

procedure f2(l:longword);
begin
end;

var
  c : TfpgColor;
  l : longword;
begin
  c:=l;
  f(c);
  f2(c);
end.



_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to