You can wrap the sizeof in static(sizeof(MyRefObject()[])) but I'm pretty sure 
the VM will complain that there is no address at compile-time.

Alternatively from the following definition
    
    
    type
        MyObject = object
            a : int
            b : int
            c : int
        
        MyRefObject = ref MyObject
    
    
    Run

You can make sure that MyRefObject is always up-to-date with MyObject 
implementation for your sizeof.

If you want one step further, you can implement a typed macro with `getType` 
and `getImpl` that resolve the ref MyObject from the MyRefObject type, and then 
statically calls sizeof on that. This is left as an exercise to the reader ;).

Reply via email to