@Sixte:

> the new keywords owned, sink and lent...

As @Araq has explained as a follow-up, they are in the library system.nim, but 
they aren't explained very well or at all in the library documentation. The 
best source of documentation for them is [the "destructors" 
document](https://nim-lang.org/docs/destructors.html). The top part of this 
page describes Nim's implementation of destructor/assignment/move semantics 
including sink/=sink (move) and the bottom part the implementation of owned 
ref, lent, etc.

@treeform:

> For Destructors what function can I call to free?

That's the point, with \--gc:destructors you don't need to call anything to 
free standard library allocated items that allocate heap space as in string's 
and seq's as this turns on the generation of =destroy/=/=sink "hooks" for these 
whose functionality is as described in the above documentation. That said, the 
default destruction time is when the binding goes out of scope at the end of a 
proc and if one wants to force destruction, =destroy can be called whenever 
immediate destruction is desired.

For your own allocated pointers, you can tap into this at any time (you don't 
need the \--gc:destuctors compiler flag) by wrapping them in an object for 
which you have defined your own custom override versions of these "hooks" that 
take care of destruction/assignment/move semantics; The compiler flag just 
makes it available automatically for the standard library structures.

Reply via email to