News for hackers. Stuff that matters.
Re:The Year of C++ Successor Languages by zozbot234 on Monday January 02, 2023 @07:23AM (#34217164)
> What exceptions do is enforcing that your working set does not have to encode any erroneous states

You do that by having types that encode a guaranteed non-erroneous state. It's not like exceptions are doing anything all that different, they're just trying to establish that guarantee in a language where variant record types and pattern matching are not first-class facilities.

This is something where C and C++ actually regressed from PASCAL, which did have support for variant records.

Re:The Year of C++ Successor Languages by mgaunard on Monday January 02, 2023 @08:35AM (#34217655)
A variant does not make that guarantee, it just segregates it.
Re:The Year of C++ Successor Languages by jstimpfle on Monday January 02, 2023 @09:55AM (#34218499)
Same for exceptions really. Exceptions don't give any guarantee of non-erroneous state. The guarantees that you're talking about actually come from how construction and deconstruction work in C++ (note how it plays with early returns just fine, no exceptions needed). And these construction semantics can be implemented with variant types as well, it's completely unrelated.
Re:The Year of C++ Successor Languages by mgaunard on Monday January 02, 2023 @05:33PM (#34224635)
The prevent the control flow from continuing in that direction, which prevents those variables from ever existing.

Early return is nothing like exceptions. Early returns needs to return something which passes the problem to someone else. It's also a choice to do it at all.

Re:The Year of C++ Successor Languages by jstimpfle on Tuesday January 03, 2023 @06:34AM (#34230268)
You're completely missing my point. The point is that both prevent the control flow from continuing in that direction. Both prevent the variables declared later to ever "exist".