Hello,

I apologize if I'm doing something totally wrong here, but hopefully someone 
can point me in the right direction. I have an application in which I would 
like to pass a pointer to a mutable object into and allow it to be changed by 
another set of procedures.

A brief mocked up example would be like below:
    
    
    type
      thing = object
        text: string
    
    proc show(obj: ptr thing): ptr thing =
      return obj
    
    proc change(obj: var ptr thing) =
      obj.text = "Goodbye World!"
    
    var x = thing()
    x.text = "Hello World!"
    
    echo show(addr x).text
    
    change(var addr x)
    echo x.text
    
    
    Run

This results in the error :

> nimtest.nim(16, 17) Error: expected type, but got: addr x

Line 16: being the `change(var addr x)` line

So, my question is: what am I doing wrong? Is what I am attempting even 
possible? I've tried a few different approached, even reading the forums here 
pointing me down a `cast[var ptr thing](addr x)` route - but that results in an 
`out of memory exception` I'd like to do this as one of the procedures down the 
line updates a sequence of RSS feeds depending on files in a directory if/when 
they change, last feed id, etc.

Again, apologies if I'm just being an idiot and trying to do something stupid - 
but I'd be happy to be pointed in the right direction!

Thanks!

Reply via email to