News for hackers. Stuff that matters.
Re:JEP draft: Exception handling in switch by wbl on Friday April 19, 2024 @04:33PM (#40091620)
Throws are nonlocal control transfer, not types. The interaction with the rest of the language is entirely different.
Re:JEP draft: Exception handling in switch by ackfoobar on Friday April 19, 2024 @05:39PM (#40092217)
Rather than looking at what the (abstract) machine does

- throws are nonlocal control transfer

- result types are adding a tag to the data or error

Think about whether the two can express the same things, and whether one can be translated to another without losing information.

Re:JEP draft: Exception handling in switch by kaba0 on Saturday April 20, 2024 @03:29AM (#40095520)
How are throws non-local? They simply pop a stackframe, the exact same way as the `return` keyword. Then the calling method gets to decide what to do, exceptions just have an implicit “unwrap-or-return/bubble up”.

Exceptions are nothing like gotos/long-jumps, it’s just “pressing escape key once vs keeping it pressed”, basically.