Hey !

Thanks you for the quick answers !

As @solo989, just returning var Child like in the snippets below does not work 
has it triggers a compile error.
    
    
    proc set_value*(self: var Child, value: int): var Child {.discardable.} =
        self.value = value
        return self
    
    
    proc get_child*(self: var Parent): var Child {.discardable.} =
        var child = Child()
        self.child = child
        return child
    
    # Raises:
    # Error: 'child' escapes its stack frame; context: 'child'; see 
https://nim-lang.org/docs/var_t_return.html
    
    
    Run

Finally, @mratsim solutions works fine and make perfect sens :) 

Reply via email to