All clr objects are stored as 
[variant](https://khchen.github.io/winim/com.html#variant) in nim. And it just 
a wrap of [win32 
VARIANT](https://docs.microsoft.com/en-us/windows/win32/api/oaidl/ns-oaidl-variant)
 .

To distinguish com variant from clr variant, clr.nim defines [following 
types](https://khchen.github.io/winim/clr.html#CLRType).
    
    
    type
      CLRType = distinct variant
      CLRVariant = distinct variant
    
    
    Run

So, they are all the same in fact. The only difference is that CLRVariant uses 
instance binding to invoking a member, and CLRType uses static binding. 
However, all return type of clr operation are CLRVariant. For convenience, `@` 
operator can be used to convert some CLRVariant into CLRType for static binding.

In your example, `IWorkbook.GetType()` returned an object of .net Type class 
and stored as CLRVariant in nim, so it cannot be used as type definition. If 
you want to define some variant before using them, you can use `var workbook: 
CLRVariant`. You can also use nim's magic 
[type](https://nim-lang.org/docs/system.html#type) to see what shoud you use. 
For example:
    
    
    proc test(): int = discard
    echo test().type # int
    
    var i: test().type
    t = test()
    
    echo clr.load("mscorlib").type # CLRVariant
    
    
    Run

Reply via email to