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

Graeme Geldenhuys graemeg.lists at gmail.com
Thu Sep 18 12:55:03 CEST 2008


On Thu, Sep 18, 2008 at 11:34 AM, Florian Klaempfl
<florian at freepascal.org> wrote:
>>
>> That's the whole point - it shouldn't be assignment compatible.  You
>> are creating a new MyString type, irrespective of what base-type it
>> was based on.  Only MyString types should be assigned to MyString
>> types, otherwise you could simply have used String type.
>>
>> I thought the example given in the delphi.non-technical discussion was
>> quite a good.
>
> It's as useless as any talk in this newsgroup. If you don't like two types
> being assignment compatible, use classes, records whatever.


If the developer wants assignment compatibility surely he could then
use the alias types??

eg: #1

type
   MyType = Double;
   MyOtherType = Double;

With the above types you should have assignment compatibility between
MyType, MyOtherType and Double.
When creating distinct types as show below, type safety should come
into play and assignment compatibility should be broken.

eg: #2

type
   MyType = type Double;
   MyOtherType = type Double;


Otherwise, what's the different between a "alias" type (eg #1) and a
"distinct" type (eg #2)??


Regards,
 - Graeme -


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



More information about the fpc-devel mailing list