On Sat, Mar 3, 2012 at 3:26 AM, Ludo Brands <ludo.bra...@free.fr> wrote: >> >> 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.
Think in my class like a Business Object. The struct is very similar with TParams it has many TParam. The data, in a TParam, is save in a Variant type. I need something like: u := TmyBO.Create; // the name does matter u.Attr['name'].Value := 'Marcos'; // an instance is created and the name is 'name' and the type is string The attributes are created on demand and the data is saved into a Variant, like TParam. If I do not use a Variant, I need to create one class to each type that I will use, right? If Variant is so bad, why TParam is implemented using it? Marcos Douglas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal