[fpc-devel] Bug in FPC and declaring distinct types

Florian Klaempfl florian at freepascal.org
Thu Sep 18 10:51:41 CEST 2008


Michael Van Canneyt schrieb:
> 
> On Thu, 18 Sep 2008, Graeme Geldenhuys wrote:
> 
>> Hi,
>>
>> I was following a discussion in the delphi.non-technical newsgroup.
>> They raised an issue about distinct types. I tried the following
>> example under FPC and unexpectedly, FPC doesn't raise any errors!
>>
>> If you declare a distinct type as follows:
>>   type TMyInteger = type Integer;
>>
>> The type TMyInteger <> Integer so you are not supposed to be allowed
>> to assign one to the other. Yet you can. See the following program.
> 
> But obviously delphi also allows it ? It compiles everything,
> just not as a var parameter.
> 
> The whole 'Type' thing is a bit ridiculous: the only reason they did it
> is so they can have different type pointers in the RTTI for something which
> is the same 'type' anyway. For the rest it is extremely badly designed, 
> and not really consistent. It serves no purpose. FPC introduced it to 
> be able to compile Delphi code, no other reason.

This is not true. The main purpose is to be able to overload 
functions/operators:

type
   TUTF8String = type ansistring;

enables you to overload all procedure already defined for ansistrings 
with UTF8String functions but reusing ansistring support functionality 
and this is supported for years. Because nobody used this yet to make an 
utf-8 unit, I never took the unicode string support serious :)



More information about the fpc-devel mailing list