lobsters score: 12 · tags: compilers
I also asked about this on Reddit, but will/won’t closures complicate this? At the closure call site you’ll have to insert invalidations based on the body, which comes earlier in the body of the enclosing function. This indicates that you have to work inside-out for the borrow checking as well, so that a closure’s
mutations_after_thisandrevived_after_thisare known. Reassigning of closures outside can either replace these (if the assignment happens outside any control flow) or add to these (otherwise).It’s not an insurmountable problem by any means, but it does sound like a pure backwards walk won’t be enough, maybe?
score 1 · canonical
Hey! Yeah, closures complicate this. I left another response on reddit too just now, but TL;DR:
My plan for closures is: When we’re doing phase 3 for a function and we encounter a closure, we gather all the group information of the arguments that we’re feeding to the closure, temporarily suspend borrow checking of the caller, and go do the full phase 3 on the closure, supplying it the parent’s group information, and ultimately calculating the mut effects of the closure.
That’s the only way to do it that I can see, so far. Luckily, it doesn’t add any more phases, it’s really just suspending one borrow check for another.
score 1 · canonical
This is really neat! It feels super elegant. The example with the loop was pure gold, I particularly enjoyed it ;)
score 1 · canonical
I’ve also had the idea that borrow checking ought to be time symmetric. I wrote about it in my proposal to add destructive move semantics to C:
https://github.com/anordal/rustlike/blob/master/proposals/destructive move.md
score 1 · canonical
