[fpc-pascal] TypeInfo question

Sven Barth pascaldragon at googlemail.com
Fri Mar 24 07:25:58 CET 2017


Am 24.03.2017 03:51 schrieb "Ryan Joseph" <ryan at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170324/6dfc5e94/attachment.html>


More information about the fpc-pascal mailing list