I agree, but ‘finally’ or ‘finish’ IMO aren’t good choice because that code doesn’t always execute.
I think I would go for something expressing ‘default’, but would first look at existing code to see how common this is, and if I decided I wanted this feature, look hard for alternative syntax.
const match: ?usize = for (text, 0..) |x, idx| {
if (x == needle) break idx;
}
could return an optional int, for example. If so, you would get a ‘null’ for free, and if you didn’t want a null, you could tack on a .getOrElse(NOT_FOUND).
“Loop statements may have an else clause; it is executed when the loop terminates through exhaustion of the iterable (with for) or when the condition becomes false (with while), but not when the loop is terminated by a break statement.”
That’s a poor analogy. He wasn’t married to multiple women at the same time. And one can have multiple relationships simultaneously without getting married five times.
You might try an other diet that‘s more filling and creates less cravings. So less carbs and more protein and fat. I don‘t think that willpower really works in this regard long term. It only creates frustrations.
> I love Rust precisely because of this. You can leverage the compiler to drive your development and design. If it's hard, then it's probably wrong!
Yes, I had the same experience writing code in Rust and Haskell. If the design works nicely with the language, then also the design is better, more modular, simpler dependencies and easier to understand and extend.
> No big plan and then engineering the small pieces to build it. I've mostly followed the small pieces that drew me at the time. I'm aware that this approach could just as likely lead you to wasting your life on whimsy and end up with nothing, but I have to say I'm surprised with how well all the parts fit together for a pleasing whole.
In a way you’ve to be lucky that your interests are valued by the time and culture you’re living in, because you can’t control them. That might be the only difference of wasting your time or making it.
> I would add that, after stack, tooling is not a problem anymore. It's not as good and polished as rust's cargo but it's ahead several other languages.
In a way Cabal 3 is even ahead of cargo, by being able of sharing build libraries between different projects and still having a sandbox like build for each project.
> There too many different ways of doing things (eg. strings, records), compiler errors need improvement, prelude has unsafe functions (eg. head), exceptions handling is not something I want in a pure language, ghc extensions change the language so much that using some extensions almost feel like having to learn another language.
For such a self called safe language, some things are almost comedy like, like getting exceptions for uninitialised record fields or unhandled alternatives in case expressions.
But Haskell still has a place in my heart and I‘m still following its development. But for my side projects Rust has replaced it, by being at some things even safer, but foremost safe at the places it‘s most important for me and also quite a bit more pragmatic. For me Rust combines the best parts of Haskell and C++.