23 ms·
Ah great! So to summarize: - we destroy a linear value either by destructuring it ourselves, or by calling a cleanup function that transitively destructures it
by _dain_ 4y ago
Ah great! So to summarize:
- we destroy a linear value either by destructuring it ourselves, or by calling a cleanup function that transitively destructures it
- we can make a type opaque to importers of our module, which precludes direct destructuring by the user
- the compiler forces the user to eventually destroy the linear value
- therefore the user must call our cleanup function
And it's our responsibility to ensure the function implements the correct cleanup logic.
- zetalyrae 4y agoYes, that's correct >we destroy a linear value either by destructuring it ourselves, or by calling a cleanup function that transitively destructures it I think I'll borrow this for the tutorial because it's very succinctly put.
- all_factz 4y agoTrying to understand: what’s to prevent someone from calling an FFI-defined function on a free type without going through the whole linear types rigmarole? E.g. could I call `fopen` and `fclose` directly to circumvent the whole `File` interface? I’m sure there’s a good answer. This is a really cool and impressive project. EDIT: Ah, just got to the section on "The FFI Boundary". Makes sense!