[fpc-devel] Re: Illegal type conversion: "<enumeration type>"to "TObject"

Jonas Maebe jonas.maebe at elis.ugent.be
Fri Jul 18 18:38:52 CEST 2008


On 18 Jul 2008, at 18:26, Craig Peterson wrote:

> Пётр Косаревский wrote:
>> 1. Why not use dummy class like "class tmyenum(tobject) e:  
>> myenumtype; end;"?
>> (extra typing is something like "(objects[i] as tmyenum).e" instead  
>> of typecasting, but you can [have to] "Free" it: it's normal object)
>
> Why would that be better than a simple typecast?  Typecasting to/ 
> from an object is a fast and easy way to associate an integer or  
> enum with the strings in a TStrings object.

Note that this will break if you turn on class type checking (-CR). In  
other words, you cannot use class type checking to check/debug  
programs that use this trick.


Jonas


More information about the fpc-devel mailing list