Ok, this might seem a little stupid. Case scenario, I’m using a lib that allows me to create a complex object which I wrap in an abstract and pass to the handling Neko code. Problem is, this abstract value requires cleanup (what abstract value doesn’t), so a close function will need to be called at some point. If I, instead, specify that the abstract value is cleaned up after using val_gc( my_abstract, close ), then does this handle calling the close function for me on this abstract without my needing to worry about calling it myself… ie, when the Neko code finishes executing?
val_gc means that the finalizer function will be called "at some point" after the value has been garbage-collected. That means that although there is no real-time warranty, there will not be memory leak either in the long run.
In your val_gc callback, you have nothing to do since your value is no longer accessible anyway, but if the "close" function is accessible directly by the user, you can do the following to ensure that any further usage of your object will not be possible :
val_kind(o) = NULL; Nicolas -- Neko : One VM to run them all (http://nekovm.org)
