Am 24.03.2017 03:51 schrieb "Ryan Joseph" <r...@thealchemistguild.com>:
> Is there anyway I could push the type checking to runtime? I wanted to
using writeln also to perform some printing for debugging but I get stuck
at compile time again trying to mix, integers, strings, records, classes
etc… in the generic. I would use an interface but there are compiler types
and records involved so that’s not an option.
>
> type
>         TLongIntMatrix = specialize TMatrix<LongInt>;
>         TObjectMatrix = specialize TMatrix<TObject>;
>
>
> function TMatrix.RetainValue (value: T): T;
> begin
>         if typeKind = tkClass then
>                 TObject(value).Retain;
>
>         result := value;
> end;
>

You could try to do it with a pointer:

PObject(@value)^.Retain;

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to