Does every linear value ultimately have to be passed to an extern function that doesn’t follow the linear typing rules?
Does every linear value ultimately have to be passed to an extern function that doesn’t follow the linear typing rules?
Whatever underlying value would be moved out of the linear record by destructuring (and thus consuming) it, then released via the underlying platform's operation (e.g. close(2), CloseHandle, ...)
edit: from the linked section, it looks like field access is a linear operation:
> when you have a linear record type, you can’t extract the value of a linear field from it, because it consumes the record as a whole, and leaves unconsumed any other linear fields in the record
so for a "newtype" (a single field wrapper type) you can just access the one field, maybe.
As long as there is interface/implementation separation, no interface that gives you the underlying handle and not enough reflection in the language to dig it out, you're solid.
Open and close must both be on the inside of the implementation so can breach the abstraction.