I can't understand why the final comparison in the code below returns false. 
XOpts.field is a reference, so passing it somewhere shouldn't change really 
change what addr returns. At least that's my assumption, but I'm obviously 
missing something here. I would be grateful if someone could clue me in.
    
    
    type
      XObj* = object
        val*: tuple[a, b: string]
      
      XObjRef* = ref XObj
      
      XOpts* = object
        field: XObjRef
    
    proc return_xobjref(opts: XOpts): XObjRef =
      return opts.field
    
    when is_main_module:
      var xobjref: XObjRef
      new(xobjref)
      xobjref.val = ("a", "b")
      var  opts: XOpts
      opts.field = xobjref
      var result = return_xobjref(opts)
      echo "IS IT THE SAME? ", (addr xobjref) == (addr result)
    
    

Reply via email to