[fpc-pascal] Re: Variant vs Pointer

Ludo Brands ludo.brands at free.fr
Sat Mar 3 07:26:54 CET 2012


> >> I need implements a similar structure but I need know if 
> the use of 
> >> Variant have very cost.
> >
> >
> > It has a cost.
> >
> > The reason for using a buffer in tdataset is that a record's data 
> > normally is located in one continuous buffer, from which a value is 
> > picked from the right spot (including strings) You can't have that 
> > with variants.
> 
> Hm... right.
> So, if I will have a class like a TParam, that have FValue: 
> Variant attribute, Would you change the implementation to not 
> use Variant?
> 

Not sure what you want to do but as Michael explained, the internal format
in tdataset is very much linked to the source of the data. Databases don't
understand pascal variants. They use only strictly typed data on the wire.
Using a variant as an internal format would only introduce overhead and
eventually data loss (fe. precision on decimals) without any gain. The
TField variant properties should be considered a convenience only and be
avoided as much as possible.

If your new class has no links with the outside world you can use whatever
you want.

Ludo




More information about the fpc-pascal mailing list