3 ms·
You don’t actually need it to be a reference; the runtime could generate a random int64 and then pass that around as a “runtime id” which could be checked when
by lalaithion 2y ago
You don’t actually need it to be a reference; the runtime could generate a random int64 and then pass that around as a “runtime id” which could be checked when used.
You’re correct that my proposal doesn’t solve every problem with Tokio. I hope someone more knowledgeable than me can write a proposal that solves all the problems.
- kelnos 2y agoI think the toplevel commenter was looking for something that could be checked at compile time. The "random int64" idea is identical to "some type that implements Copy", and would require runtime verification, which is not really an improvement on the current state of affairs.
- lalaithion 2y agoIt would prevent callers from not knowing the function depends on a specific runtime. That’s a huge improvement in my opinion. I expect something along the lines of the GhostCell paper could be used to implement this, to be honest, but I think it would be more verbose than necessary. (Really, we need an effects system, and then Tokio could just be an effect that contains, but is different from, async)
- saghm 2y ago> which could be checked and used Checked where? In global mutable state you mentioned that has to be created beforehand in the same way you mention? I don't really see how this changes much other than making everything more verbose from the extra argument. It would be nice for someone to come to with a new solution to solve everything, but I don't think it's as simple as just "use an id and then tidy up some remaining details". No one has come up with something more compelling yet because those details are where the fundamentally are part of the problem is. When the hard problem is figuring out semantics that will allow exposing a better API, proposing an API and then hoping someone finds a way to make it work under the hood is just backwards.
- lalaithion 2y agoThe verbosity is the point! I want functions that interact with a specific expectation of global state to clearly mark that in their type, and the least complicated way to do that is my proposal. I hope someone can invent something more compelling, but my proposal is still an improvement of the status quo.