You don't need `var` in any of those procs because you are using ref objects 
and you are modifying the memory pointed to by the reference, not the reference 
itself.

i.e. this compiles
    
    
    type
        Child* = ref object
            value: int
        
        Parent* = ref object
            child: Child
    
    
    proc set_value*(self: Child, value: int): Child {.discardable.} =
        self.value = value
        return self
    
    
    proc get_child*(self: Parent): Child {.discardable.} =
        let child = Child()
        self.child = child
        return child
    
    
    let parent = Parent()
    
    parent.get_child().set_value(10)
    
    
    Run

Reply via email to