Now that finalizers work fine with --gc:arc there are two questions left: [https://nim-lang.org/docs/system.html#new%2Cref.T%2Cproc%28ref.T%29](https://nim-lang.org/docs/system.html#new%2Cref.T%2Cproc%28ref.T%29) >Note: The finalizer refers to the type T, not to the object! This means that for each object of type T the finalizer will be called!
If that a fundamental restriction, or is that done only to not waste 8 bytes for a pointer to the actual finalizer in each instance? The point is, that there may exists circumstances where one really wants a finalizer bound to each instance. One example are objects returned from gtk libs. In most cases function results are of type "transfer full", indicating that user takes ownership and has to free the object. For this case we employ a finalizer. But there are cases where gtk still owns the object, and we would not need a finalizer. In really rare cases for the same class these two cases are mixed. That is a problem in Nim, because for the same proxy object we have to decide if we employ a finalizer or not. Of course we can solve this easily when we give the proxy object a boolean field indicating if the finalizer shall really free the gtk object or just do nothing. The other question is about the fact that finalizer has to be defined in the same module as the object is defined. Finalizer allows bindings the same function multiple times now, which is very useful. I assume that the restriction to one module is because the compiler can not ensure that always the same function is used as finalizer for instances of an object if the finalizer proc lives in a different module? (This is indeed no serious restriction, I can simple copy the gobject finalizer proc into each module that uses subclasses of gobject.)
