Board index » delphi » NULL&Unassigned to Variant referencing an interface

NULL&Unassigned to Variant referencing an interface

The silly question is boring me. What is the difference between assigning
NULL and Unassigned values to Variant variable containing interface? It
seems for me that both will destroy the interface (at least ref counting
will be performed). But I wish to know exactly the compiler behaviour.
 

Re:NULL&Unassigned to Variant referencing an interface


<<Dmitri:
What is the difference between assigning NULL and
Unassigned values to Variant variable containing interface?
It seems for me that both will destroy the interface

Quote

Well, I suppose if the variant contained an interface, it
won't any more - same as if you put (say) an integer into
the variant. But an Unassigned variant is officially
'empty' - VarIsEmpty will return true. Variants are
initialized to Unassigned, and VarClear makes them
Unassigned again. A Null value, OTOH, is just a special
value that can be assigned to a variant. It's a bit like
the difference between a database field with a zero value,
and one that hasn't been assigned any value at all.

--
Deborah Pate (TeamB)
http://delphi-jedi.org
Sorry, no email please.

Re:NULL&Unassigned to Variant referencing an interface


Why then DCOMConnection.DoDisconnect reset AppServer interface variable to
NULL instead of Unassigned value?

Deborah Pate (TeamB) <d.p...@cableinet.co.not-this-bit.uk> wrote in message
news:VA.00000469.005fd0fc@cableinet.co.not-this-bit.uk...

Quote
> <<Dmitri:
> What is the difference between assigning NULL and
> Unassigned values to Variant variable containing interface?
> It seems for me that both will destroy the interface

> Well, I suppose if the variant contained an interface, it
> won't any more - same as if you put (say) an integer into
> the variant. But an Unassigned variant is officially
> 'empty' - VarIsEmpty will return true. Variants are
> initialized to Unassigned, and VarClear makes them
> Unassigned again. A Null value, OTOH, is just a special
> value that can be assigned to a variant. It's a bit like
> the difference between a database field with a zero value,
> and one that hasn't been assigned any value at all.

> --
> Deborah Pate (TeamB)
> http://delphi-jedi.org
> Sorry, no email please.

Re:NULL&Unassigned to Variant referencing an interface


Quote
"Dmitri" <udmi...@newmail.ru> wrote in message news:3a05a90a_1@dnews...
> Why then DCOMConnection.DoDisconnect reset AppServer interface variable to
> NULL instead of Unassigned value?

It's not very relevant because this still works. But the convention for
clearing a variant should be Unassigned or VariantClear().

have fun
--
Binh Ly
http://www.techvanguards.com

Other Threads