Re:Rust vs. Go in 2023
by amedvednikov on Sunday August 13, 2023 @04:04AM
(#37107700)
V uses Result types for handling errors, and the developer must handle them by propagating the error or breaking/returning or panicing.
For example:
// os.v
fn open(path string) !File {}
// main.v
file := os.open('out.txt') or { panic('failed to open: $err') }
file := os.open('out.txt') or { return }
file := os.open('out.txt')! // propagate the error
if file := os.open('out.txt') {} // alternative scoped syntax
Re:Rust vs. Go in 2023
by fuzztester on Sunday August 13, 2023 @04:44AM
(#37107906)
Thanks. Will check those out more.
V syntax looks somewhat clear.
Re:Rust vs. Go in 2023
by fuzztester on Sunday August 13, 2023 @04:59AM
(#37108016)
Thanks.
V syntax looks somewhat clear.
How does that work in practice? Example please.