10-25-2011 10:41 AM
Anything can be stuffed in variant.
Ben
10-25-2011 11:32 AM
The variant is prefered because it can have attributes (private data that also passes on the varient wire) attrubutes are often used for state cashe information or other useful information about the data. a common example is attribute.IsInit? as a boolean for talking to an instrument control queue.
10-25-2011 11:56 AM
Ben, yes, anything can be stuffed into a variant....but anything can be flattened to a string as well.
The only reason is that variants have attributes? Seems reasonable. I guess I'll buy that.
10-25-2011 12:06 PM
@craige wrote:
Ben, yes, anything can be stuffed into a variant....but anything can be flattened to a string as well.
The only reason is that variants have attributes? Seems reasonable. I guess I'll buy that.
Well, that and the cool purple color!! Flattened strings are sometimes miswired / mishandled because of the wire color. This is not a problem with varients
10-25-2011 12:12 PM
Also, you don't have to explicitly flatten to string everytime you want to add to the queue. You can wire your data directly into the variant.
It's also easier for debugging, since, in many cases, the variant will show what's stored in it. You'd have to be Neo to look at a flattened string and decipher the thing.
10-25-2011 12:46 PM
And one more -
variants (as far as I know) aren't flat, meaning that the data contained in a variant can have pointers in it and be in multiple locations in RAM.
A flattened string is, by definition, flat, which means that if the original data isn't flat it needs to be flattened which can cost you some RAM and CPU cycles. I suppose a variant could (at least theoretically) get by without creating a copy if it can simply point to the original data, but that's just a guess.