Closed bitcompost closed 1 year ago
Foreign objects (especially ones that need special handling like custom gc behavior) should generally be implemented via abstract types. One of the fields in abstract types is the gc field (there's also a gcmark field) that binds to a function pointer that does exactly that.
Thanks, this is what I was looking for. I found a nice guide on abstract types: https://janet.guide/xenofunctions/ . Would be nice to have something in the official Janet docs.
Hi, does Janet have anything similar to finalizers for foreign objects in Guile, or __gc metamethod in Lua? I only found janet_sfinalizer for scratch memory, if I understand correctly, scratch memory is always freed on next gc so that's not what I'm looking for.
Thanks!