3 ms·
Oh right, fair enough. I usually end up doing the Go style in C# anyway; the from ... syntax usually leaves other devs unconvinced and suspicious.
by taberiand 4y ago
Oh right, fair enough. I usually end up doing the Go style in C# anyway; the from ... syntax usually leaves other devs unconvinced and suspicious.
- lalaithion 4y agoHaskell could have (I don't know a library that implements this, but it's ~trivial) do x <- open filename `errorContext` ("failed to open " <> filename) y <- readBytes x `errorContext` "failed to read bytes from file" Rust has let x = open(filename).with_context(|| format!("failed to open {}", filename)?; let y = read_bytes(x).with_context(|| format!("failed to read bytes from file")?; or if we ever get https://github.com/joshtriplett/rfcs/blob/simple-postfix-macros/text/2442-simple-postfix-macros.md https://github.com/joshtriplett/rfcs/blob/simple-postfix-mac..., let x = open(filename).with_context!("failed to open {}", filename)?; let y = read_bytes(x).with_context!("failed to read bytes from file")?;