Stream: wasmtime

Topic: never use unwrap?


view this post on Zulip Dan Gohman (Mar 06 2020 at 19:30):

What is the goal of "never use unwrap"? @Alex Crichton

view this post on Zulip Alex Crichton (Mar 06 2020 at 19:31):

My thinking is that unwrap() runs the risk of triggering a panic, and panics in general are bugs we should always be fixing

view this post on Zulip Alex Crichton (Mar 06 2020 at 19:31):

So in some sense we want to make sure that wasmtime never panics, and if we never use unwrap() that's one vector of panics we could completely remove

view this post on Zulip Alex Crichton (Mar 06 2020 at 19:32):

It makes it easy to audit, for example, if unwrap() is never present, whereas otherwise we have to understand contextually what's happening and consider whether the comment about why the unwrap() never panics is correct

view this post on Zulip Alex Crichton (Mar 06 2020 at 19:32):

that's my thinking at least, it's not too advanced nor too strong at all, I don't particularly mind one way or another

view this post on Zulip Dan Gohman (Mar 06 2020 at 19:34):

I come from a background which is more inclined to worry that by translating "impossible" conditions into runtime errors, you make them more likely to be silently swallowed, when what you really want to do is re-evaluate your assumptions.

view this post on Zulip Dan Gohman (Mar 06 2020 at 19:34):

But I expect it depends a lot on an assumption that surrounding environments will ultimately be ok with a panic now and then.

view this post on Zulip Alex Crichton (Mar 06 2020 at 19:35):

nah that's a good point

view this post on Zulip Alex Crichton (Mar 06 2020 at 19:35):

and silently swallowing errors is arguably worse than getting a bug report for something we should actually fix


Last updated: Nov 22 2024 at 16:03 UTC