[fpc-devel] type question

Christian Iversen chrivers at iversen-net.dk
Sat Oct 14 23:00:14 CEST 2006


On Saturday 14 October 2006 17:38, Peter Vreman wrote:
> > On Saturday 14 October 2006 15:55, Marc Weustink wrote:
> >> Hi,
> >>
> >> if I define 2 types like:
> >>
> >> type
> >>   MyA = type string;
> >>   MyB = type string;
> >>
> >> are MyA and MyB considered as the same type ?
> >
> > No, you are explicitly marking them as a new type. This is a very cool
> > feature
> > of Pascal you wont find in many other languages.
> >
> > (For instance, you could use it to create a new integer-type for little-
> > and
> > big-endian numbers, ensuring that you _never_ directly assign a
> > little-endian
> > number to a big-endian one, or vice versa)
>
> For the compiler the types are not equal anymore, but they are still
> compatible for implicit type conversion. This has mainly impact on
> overload choosing and parameter passing. Normal assignments using ':=' are
> not affected because of the still available implicit type conversion.

I really feel there should be a way to make two types completely incompatible.

How exactly does the compiler figure out the rules for implicit conversion?

In the case of wrapper integers in records, are 4-byte records handled as 
efficiently by the compiler as 4-byte integers? I suspect it's some radically 
different code that handles it.

-- 
Regards,
Christian Iversen



More information about the fpc-devel mailing list