On Fri, Aug 8, 2025, at 07:57, Mihail Liahimov wrote:
> Yeah, it seems to be problematic to use this syntax with finally blocks. 
> Perhaps the optional catch block should be allowed only at the very end, but 
> it sounds somehow doubtful.
> 
> ср, 6 авг. 2025 г. в 16:52, Andreas Heigl <andr...@heigl.org>:
>> Hey Mihail
>> 
>> Am 06.08.25 um 13:34 schrieb Mihail Liahimov:
>> > Hi!
>> > 
>> > At the moment, I can suggest this syntax:
>> > 
>> > try {
>> > // do something
>> > } catch (SomeIgnorableException) finally {
>> > // do something
>> > }
>> > 
>> I find that ... challenging
>> 
>> When reading the code I now have to go to the end of the line to 
>> understand that the second
>> 
>> // do something
>> 
>> does not belong to the `try` but to the `finally`...
>> 
>> 
>> And
>> 
>> try {
>>    // break stuff
>> } catch (SomeIgnorableException)
>> finally {
>>    // do something regardless
>> }
>> 
>> seems boken due to the missing }
>> 
>> But well....
>> 
>> We just have to adapt to something like this:
>> 
>> try {
>>    // break stuff
>> }
>> catch (SomeIgnorableException)
>> catch (Some OtherIgnorableException)
>> finally {
>>    // do something regardless
>> }
>> 
>> -- 
>>                                                                ,,,
>>                                                               (o o)
>> +---------------------------------------------------------ooO-(_)-Ooo-+
>> | Andreas Heigl                                                       |
>> | mailto:andr...@heigl.org                  N 50°22'59.5" E 08°23'58" |
>> | https://andreas.heigl.org                                           |
>> +---------------------------------------------------------------------+
>> | https://hei.gl/appointmentwithandreas                               |
>> +---------------------------------------------------------------------+
>> | GPG-Key: https://hei.gl/keyandreasheiglorg                          |
>> +---------------------------------------------------------------------+

What about instead of at the end, we do it at the beginning?

try ignore (SomeIgnorableException, OtherException) {
  // break stuff
} catch(UnexpectedException) {
  // fix stuff
} finally {
  // do this anyway
}

Since ignore only can follow a try and any symbol other than a "{" is currently 
an error, I don't think we don't need to reserve "ignore" as a keyword.

It appears to be relatively easy to scan/read as well.

— Rob

Reply via email to