[fpc-pascal] Alternative to generic advanced records
Kornel Kisielewicz
kornel.kisielewicz at gmail.com
Tue Feb 7 19:52:45 CET 2012
Ok, advanced records in 2.6.0 are it seems buggy as hell (with
optimizations on), so I'm searching for an alternative. For the simple
case objects work quite well, but for generics I have a problem.
This is part of the code:
generic TGVector3<T> = packed record
{... types}
public
class function Create( aX : T = 0; aY : T = 0; aZ : T = 0 ) :
TGVector3; static;
{... functions}
class operator +( const A, B : TGVec3 ) : TGVector3;
{... other operators}
class operator Explicit( const A : array of T ) : TGVector3;
{... properties etc}
end;
The generic record has a lot of utility functions and operators, and
is used in specializations for Single, Double, Integer, Byte and one
custom type, so rewriting it as not-generic is out of the question.
Now, I'd really like to convert it to an object, but objects do not
support built-in operators (or do they?). Any ideas how to circumvent
that?
--
regards,
Kornel Kisielewicz
http://chaosforge.org/
More information about the fpc-pascal
mailing list