Conversation

@yosh Maybe “pause points”? The callee pauses itself and may or may not be resumed later on.

0
0
0
@yosh Is that not a bit beside, or at least not fully explaining the usual definition of a "linear type," e.g. a type that is used exactly once?

(proper linear types is something I would love to see in Rust in the future, though there has not really been too much interest in it)
0
0
1
@yosh I wrote some code for my masters where I need to guarantee that all values are consumed, so I ended up thinking quite a bit about this but ended up using macros to find cases where values are not consumed which is a bit fragile. [0,1]

And yeah it needs to be handled at any place where the function may end, I think that it would also work better for some things that are now finalized in the Drop, but may error which means that an error may be unhandled.

[0]: https://blog.erk.dev/posts/rrust/
[0]: https://github.com/erk-/rrust
0
0
2
@yosh
@Gankra wrote a blog post about this some years back with some of the pains around it, and they come to more or less the same conclusion

https://faultlore.com/blah/linear-rust/
0
0
1

@yosh I think you could even hold a linear type across a control point, as long as the holder then becomes a linear type. Sort of like holding a !Send value across an await point makes the future !Send.

0
0
0

@yosh I really need to go read up on some effect literature again...

0
0
0

@yosh Unfortunately it doesn't solve the `mem::forget` issue as long as we have `Rc` and `RefCell`, since you can build a circular list and then drop your handle to it but the list keeps itself alive.

0
0
0

@yosh Ah, so you'd just make it illegal to put linear types in an Rc or RefCell? Actually, probably just RefCell would be sufficient (and Mutex and similar...). That seems like that could be overly limiting though?

0
0
0