[fpc-devel] Re: Illegal type conversion: "<enumeration type>"to	"TObject"
    Craig Peterson 
    craig at scootersoftware.com
       
    Fri Jul 18 18:26:19 CEST 2008
    
    
  
Пётр Косаревский 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.  We know when we're doing this, and 
TStrings never does anything with the object, so the alternatives add 
runtime and code overhead that simply isn't needed.  Even if this was a 
one off thing I'd question introducing an object for it, but in our case 
there's literally dozens of spots where we use the technique with many 
different enumerated types.
Craig
    
    
More information about the fpc-devel
mailing list