Re: Why is my destructor not called?

2018-03-16 Thread matkuki
Oh, seems the **\--newruntime** compiler flag is needed for destructors to work.

Re: Why is my destructor not called?

2018-03-15 Thread lotzz
> I am on Windows 10, Nim Compiler Version 0.18.0 [Windows: i386], MinGW GCC. I don't know if that is just for windows 10, I am on ubuntu with 0.18.0 and I am getting the same thing though my code is a little different {.experimental.} type thing = object x:int p:poi

Re: Why is my destructor not called?

2018-03-10 Thread matkuki
Hi, Is there a regression in the compiler, because the above example doesn't execute the destructor: {.experimental.} type MyObj = object a: int proc `=destroy`(m: MyObj) = echo "Destruct" proc works() = let x = MyObj(a: 5)

Re: Why is my destructor not called?

2018-01-12 Thread Udiknedormin
@sendell Not necessarily. Global scope can be unique in some ways, although I agree it could be quite confusing in Nim specifically. That's the way things are in some languages, for example: * in C, global variables can't be initialized in a function call (they can in C++) * in Fortran, glo

Re: Why is my destructor not called?

2018-01-11 Thread sendell
Global scope should work as any scope, and call destructors when ending. > adianv said: why should it be called ? x is global and gets never out of > scope. The whole point on RAII is to be abble to bind the lifetime of a resource to the lifetime of an object, to make sure the resource is relea

Re: Why is my destructor not called?

2018-01-10 Thread Araq
Oh yeah, good to know this doesn't work.

Re: Why is my destructor not called?

2018-01-07 Thread twetzel59
adrianv, that makes better sense now. Udiknedormin, I agree here. I think that a block should lead to deconstruction.

Re: Why is my destructor not called?

2018-01-07 Thread Udiknedormin
Well, it is not an issue but I don't get why it doesn't work for a block: {.experimental.} type MyObj = object a: int proc `=destroy`(m: MyObj) = echo "Destruct" block: let x = MyObj(a: 5) I find it misleading as a block should creat

Re: Why is my destructor not called?

2018-01-06 Thread adrianv
why should it be called ? x is global and gets never out of scope.

Why is my destructor not called?

2018-01-05 Thread twetzel59
Hello, I have a question about destructors. I am not sure if I am misunderstanding something, or if this is a bug. When I declare a constructor for a type, it is not called if an instance of the object is created free in the main module (as opposed to within a proc). For example, the destructor