Using the Variant (Setting it's memory location)

Era Scarecrow rtcvb32 at yahoo.com
Mon Feb 6 16:38:59 PST 2012


> Variant allows you to store any value, but it does not need a 
> buffer or have interaction like an array. It can hold any value 
> because it the size of the data structure is the max size of 
> the times it can hold. For this reason it can not actually hold 
> any structure.
>
> For an array of any values you use a Variant[] foo = new 
> Variant[100].
>
> foo[0] = myInt;
> foo[1] = myFloat;
>
> However depending on the length of char[static size], you may 
> need to give Variant a larger maximum size.

Unfortunately I'd need to reference a buffer for the known 
structured types. Variant seems far more useful for making an 
interpreted language, than for my purposes.

I'll just have to simplify the access/reading/writing structures 
to basically doing just that (Drop any compare and added 
complexity), and use native data types to handle and work with 
the data.


More information about the Digitalmars-d-learn mailing list