[fpc-devel] Bug in FPC and declaring distinct types
Michael Van Canneyt
michael at freepascal.org
Thu Sep 18 11:12:38 CEST 2008
On Thu, 18 Sep 2008, Florian Klaempfl wrote:
> 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;
Well, that was not so for delphi. The delphi help explicitly says:
"if your purpose in defining a new type is to utilize runtime type
information--for example, to associate a property editor with properties of
a particular type--the distinction between "different name" and "different
type" becomes important. In this case, use the syntax"
I've lived with this knowledge for years :-)
>
> 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 :)
Aha, in that case, you should have told me this so I could document it !
I cannot see inside your head, you know :-)
Maybe make a backup of your brain and send it to me ?
A 1Tb. external disk is no longer so expensive :-)
Michael.
More information about the fpc-devel
mailing list