WebAssembly / component-model

Repository for design and specification of the Component Model
Other
933 stars 79 forks source link

Refactor Python definitions related to `borrow` handles #215

Closed alexcrichton closed 1 year ago

alexcrichton commented 1 year ago

This commit is at attempt of mine to simplify the moving parts in how handles are specified by refactoring the related Python code which specifies how everything works. Previously I found the interactions between the various methods difficult to understand due to some layers of abstraction and where various methods were invoked. Here I've attempted to (subjectively at least) simplify a few things:

Overall to me at least this felt easier to understand where there are seven basic primitives here: resource.{new,rep,drop} plus {lift,lower}_{own,borrow} and all seven now relatively clearly document, just by looking at their single method, what each primitive is responsible for. Previously methods had to be followed to understand how the borrowing/own dynamic tracking all interacted but it's, at least in theory, more up-front now.

alexcrichton commented 1 year ago

Oh I forgot to mention this above as well but my intention here is to preserve the exact same runtime semantics as before, only structure the code differently. I think I've managed to maintain that here but if it looks like I changed something semantically that's a mistake.

lukewagner commented 1 year ago

Works for me, thanks.