3 ms·
> There is plenty of code that is guaranteed not to throw -- starting from operations on basic types This is fair, although this places some mental load on the
by Expurple 2y ago
> There is plenty of code that is guaranteed not to throw -- starting from operations on basic types
This is fair, although this places some mental load on the programmer because they need to be careful when dealing with generics / operator overloading or when extracting helper functions.
> noexcept functions if we are talking about C++
This is a good C++-specific guarantee. But it's probably outweighted by the C++-specific lack of guarantees. "Operations on basic types" can now invoke UB, if we are talking about C++.
> Isn't it too much clutter?
In cases with one generic parameter, like the ones I demonstrated, I think it looks ok. Normal generic code. Rust generics are only going to require less ceremony in the future, because the team keeps making progress on implied bounds, lifetime elision, 2024 lifetime capture rules.
> What if a function has three arguments? You'd need three generic parameters for their errors.
This really depends on the context and what the code actually does, and needs a concrete example to discuss. I don't remember seeing a real world example with three Result parameters, nevermind having generic but distinct errors in them.
- protomolecule 2y ago>careful when dealing with generics / operator overloading In C++, you can't overload operators for built-in types and template parameters are normally constrained: auto f(std::integral auto x) noexcept { return x+x; } But yes, writing C++ templates that work with wide range of types takes some thinking and operator overloading adds to the mental load (or reduces it, when used sparingly and properly). >"Operations on basic types" can now invoke UB They always could. I don't want this conversation to become about Rust vs. C++, I'd gladly use Rust when where is appropriate task. >needs a concrete example to discuss Write a new post when you come up with a bunch of good examples)
- Expurple 2y agoSure. Thanks for the conversation. If you're interested in the follow up, I have an RSS feed: https://home.expurple.me/posts/index.xml https://home.expurple.me/posts/index.xml
- protomolecule 2y agoThanks! What do people use nowadays to follow rss? A telegram bot perhaps?
- Expurple 2y agoHonestly, no idea. I got into RSS about a year ago. I just use Thunderbird, which I already use for my mail
- protomolecule 2y agoI'll see how this one works: https://t.me/FeedRiverBot https://t.me/FeedRiverBot