-
Notifications
You must be signed in to change notification settings - Fork 89
Should {future,stream}.close-{readable,writable}
take ownership of the error-context?
#469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Keep in mind that |
My current understanding is that your last statement is inaccurate, but let me double-check as I may be wrong:
My understanding of What I'm wondering is whether it would make sense to remove the |
Oops, I skimmed the last part of Joel's comment too quickly before 👍 . You're right that there is no reference count: a single call to |
We could consider a switch to move-semantics, like |
OK, I guess I misunderstood, and the implementation in Wasmtime will need to be redone. My understanding was that if I pass an |
Personally I'm a fan of always- Thinking about this it's an interesting point I've not fully internalized before, but ownership semantics are more-or-less "no cost" in Rust/C/C++ but are costly in GC'd languages (like JS) since you have to "take" from an object and then have runtime checks to make sure you don't take twice. Conversely borrow-like semantics are "no cost" in GC'd languages (just clean up on a GC of the object) but are costly in Rust/C/C++ as you have to take care to connect the usage of the value to happen before the destructor. For borrow-semantics it's possible to make that no-cost in Rust/C/C++ so long as something isn't persisted outside of a function call, but once it's persisted beyond a single function call it's (IMO) infeasible to model in C/C++ and requires lifetimes in Rust which may or may not be possible. All in all, even if I try to set aside my Rust biases (which I know I can't fully do), I feel like |
Overall, I think switching to transfer semantics and adding an Your comment does bring up the fact that the transfer semantics requires an extra internal mutation in cases where I have a GC object containing an |
Personally I wouldn't be certain whether that tradeoff is right or whether the current non-ownership model is best. It's clear to me how to articulate the pros/cons, but weighing them I'm less certain... One possible tweak though I'd make is could we remove |
If the idea is that |
Oh good points! Ok In that case if we go with owning semantics I agree |
Yeah, I'm ambivalent; even moreso because, since we're on the error path, we're not so concerned with every cycle. @dicej any suggestions? |
I'll admit I've only been half-following this issue, but owning semantics sounds fine with me. If we think we can do without BTW, @vados-cosmonic is currently the expert on the |
Ah thanks for the heads up @dicej , yeah I've been watching this thread and with regards to the semantics, I don't have a bias really here but I am concerned mostly with least-surprise. In $LANGUAGE, bindings will have to provide some sort of
(1) and (2) we can do now, and (3) we can do only at construction right now, and the rest (3-5) are all in the future. In this context, I think that owned semantics w/ transfers + a new Some more use cases that I think might be worth considering for impact:
I think that ref-counted versus owned w/ transfers mostly works the same in this case, but I think the ref-counted approach would require much more intricate/inefficient tracking during implementation of the above? I'm not sure what we wanted to gain from ref-counting in the first place though, so maybe there's something I'm missing. A separate thought, but is this a "two way door"? -- can we imagine a world where we add options that facilitate operations on error contexts that are always "borrowed" in every component they're in? Some sort of |
One tweak I'd make to the above future-additions list is: while I think we do need to support extending an |
Hey @alexcrichton this can probably be closed since we're moving error-context out of these APIs |
I've scheduled this to be closed with #489 |
Currently in the canonical ABI these intrinsics only acces the error-context rather than consuming it, like a
borrow<_>
instead ofown<_>
. My (possibly naive) expectation though would be that in the majority of cases that an error context is passed in and then discarded, so should this perhaps both take anerror-context
and remove it from the component's table?The text was updated successfully, but these errors were encountered: