Lets start with:
    
    
    type
      Page = ref object
        title: string
    
    var pages: seq[Page]
    pages.add Page()
    
    
    Run

So both of these functions compile and both work, with --newruntime, but which 
one is correct?
    
    
    proc popPage(): Page =
      return pages.pop()
    
    
    Run

or
    
    
    proc popPage(): owned Page =
      return pages.pop()
    
    
    Run

I am thinking the 2nd one is correct because the pages who who ever at the 
pages scope no longer have a ref to Page so they would no longer own it.

I am surprised the 1st one even compiles. What is the difference between the 
two function definitions?

Reply via email to