Before you relieve the itching in your fingertips, I already understand:
- how and when to use the
try
keyword - the differences between the
try
,try?
, andtry!
keywords
What I want to understand is what the use of the unadorned try
keyword buys me (and you and all of us) over and above merely quieting a compiler diagnostic. We're already inside the scope of a do
, and clearly the compiler knows to demand a try
, and I can't (yet) see how there might be some ambiguity about where the try
needs to land. So why can't the compiler quietly do the right thing without the explicit appearance of the keyword?
There's been a fair amount of discussion (below) about the possibility that the language is trying to enforce readability for humans. I guess we'd need the input from one of the Swift language designers to determine whether that's true. And even if we had that it would be debatable whether it's wise and/or has been a success. So let's put that aside for the moment. Does the existence of the un-adorned try
keyword solve some problem other than enforcing readability for humans?