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

Graeme Geldenhuys graemeg.lists at gmail.com
Thu Sep 18 10:02:11 CEST 2008


On Thu, Sep 18, 2008 at 9:42 AM, Michael Van Canneyt
<michael at freepascal.org> wrote:
>>
>> 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.

Which still doesn't discount it as a bug in both FPC and Delphi!  At
least in Delphi it fails on the var parameter, so it's 50% there - it
should really fail on both counts.  You are not allowed to do that
(assign different types) with any other types, so why allow it with
custom made types??


> 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.

I'm not going to get into the whole argument about the usefulness of
distinct types - for that you can read the thread posted in
delphi.non-technical titled: "Generics. How can I?" dated 2008-09-15

All I can say, is that distinct types (custom made types) are used all
over the place, in Delphi, Lazarus, fpGUI and I'm pretty sure FPC as
well. It's a handy language feature and should allow type safety like
all other types.


Regards,
 - Graeme -


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



More information about the fpc-devel mailing list