On Thursday, 31 March 2022 at 22:05:30 UTC, mee6 wrote:
>On Thursday, 31 March 2022 at 21:35:00 UTC, user1234 wrote:
>On Thursday, 31 March 2022 at 21:21:04 UTC, mee6 wrote:
>Rust's error handling is pretty good, I think they've proved the use of Result!(T, E). I was just always getting informative messages from the get go. I think there's a @nogc exception DIP in the works but I think this way of handling errors is better.
I won't go too much into detail of rust as this website does a good job of going over it.
https://doc.rust-lang.org/book/ch09-00-error-handling.html
Anyways this could be adopted instead of trying to get @nogc exceptions working. Rust uses exceptions but only for panic!() Which terminates the application. All it does is rewind the stack to see all the function calls for debugging pretty much.
I also think it works with chaining functions as that's what Rust does a lot too. They have a ?
operator that does basically this boiler plate code.
auto result = expr;
if (result.isErr())
return result;
D could implement this fairly easily and without much intrusion, but it would add a lot of value to be able to do something like:
auto value = chain()?.funcs()?;
yikes, I'd prefer if D could use ?
for safe navigation.
While being @nogc and without using exceptions. Other than for panics.
That is Rust's equivalent.
https://en.m.wikipedia.org/wiki/Safe_navigation_operator#Rust
yeah, nice. Everyone needs to see that and think twice.
Is Rust awefull afterall ?