2 ms·
But you could have ADTs without using them for 'forced error handling', and you could have 'forced error handling' without using ADTs for it - C could require '
by OJFord 5y ago
But you could have ADTs without using them for 'forced error handling', and you could have 'forced error handling' without using ADTs for it - C could require 'consumption' (for a slightly less strict meaning of it) of return values. That's the bit I think is interesting/was new to me. You can't just call `maybe_works();`, you have to explicitly consume its 'result', even if just to propagate the error as `maybe_works()?;`.
- monocasa 5y agoOh, ok. Yeah that in fact does exist in C and C++ the same way as in Rust. Rust doesn't actually by default require you to consume a return value; a lot of functions are just marked as #[must_use]. C and C++ do the same thing with [[nodiscard]] and __attribute__((warn_unused_result)). There's a go vet pass as well. https://pkg.go.dev/github.com/golangci/govet#hdr-Unused_result_of_certain_function_calls https://pkg.go.dev/github.com/golangci/govet#hdr-Unused_resu...