> need to define your destructor earlier

Yes, my initial guess was indeed that, as it was done in that way in the 
earlier gintro code.

But I became unsure if it would work really fine also that way.

And it remains strange, as my fnew template should fully hide the use of the 
finalizer when we compile with --gc:arc. So I assume that both branches of the 
when construct are processed by the compiler and that confuses the compiler? In 
the same way as discarded code is always syntax checked?

Unfortunately ordering the code is not that easy, as it is autogenerated from 
the gobject-introspection database, and for latest gtk 3.98.3 which will become 
4.0 there are some serious changes. I can not just put the =destroy just after 
the type declaration, as =destroy calls low level procs like 
gdk_event_unref(self.impl) above. So carefully sorting will be necessary.

Note that forward declarations like below do not compile:
    
    
    proc gdk_event_unref(self: ptr Event00)
    
    proc gdk_event_unref(self: ptr Event00) {.importc, libprag.}
    
    
    Run
    
    
    Error: pragmas are only allowed in the header of a proc; redefinition of 
'gdk_event_unref'
    
    
    Run

What should work is declaring a special unref function before declaring the 
=destroy and using that one in the =destroy like
    
    
    proc destroy_gdk_event_unref(self: ptr Event00) {.importc: gdk_event_unref, 
libprag.}
    
    
    Run

Reply via email to