Enhanced 'do' Block Syntax and Error Handling

I'm having some trouble in Swift these days when Control Flow blocks and expressions get the same name, telling apart when when I'm doing legit Control Flow and when I'm in a multi-line expression with an implicit(!!!) return.

The most recent was my confusion was with result builders that the "for" in that is really more of a foreach {}

So all of a sudden do and catch will be sometimes be expression and sometimes Control Flow?

I don't mind having both CF and expression but how do I know which I'm doing if they have the same name? Maybe a "doSet" and "catchSet" would be okay? But people seem to really want the same names for these very different creatures? That's the part I don't understand.

Is this just the way modern languages do things? Could someone point me at a paper or a youtube video or give me some search terms so I can educate myself on why everyone hates control flow programming and wants expressions to overload those terms? Is it just "functional programing" and I just need to do it? I get the value of no side effects... but then on the other hand we have people adding ~Copyable and borrow to the language too, which seem all about a return to side effects, really.

Honestly, I'm flexible and can learn so I defer to what the community wants but I'd love some resources so I can understand the debate better.

Ah, the ship seems to have sailed and I'm just going to have to write C++ libraries now :joy: :wink: [Accepted with modifications] SE-0380: `if` and `switch` expressions (This is very much a joke. I will enjoy not writing return in my switch statements with everyone else!)

1 Like