How could you ever continue after the second statement without checking if you actually read an integer or not? How would you know what you can do with a?
I agree. It's lunacy. just be explicit and use functions or equivalent like literally every other language.
I believe Rust has adopted similar idioms. I’ve heard the overall idea referred to as Railway-oriented programming.
In C++ you could implement it with exceptions, though they bring in a bunch of their own baggage that you don’t have to deal with when using monads.