[v2] replace else-clause on loops/try with a different keyword

Discuss the future of the AutoHotkey language

iseahound
Posts: 1444
Joined: 13 Aug 2016, 21:04
Contact:

Re: [v2] replace else-clause on loops/try with a different keyword

Post by iseahound » 01 Mar 2023, 16:08

continue? Else works fine here semantically speaking, but does interfere with the if-else construct.

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: [v2] replace else-clause on loops/try with a different keyword

Post by swagfag » 01 Mar 2023, 18:30

continue what? continue is already a keyword. a new (different) one is needed. one that would make sense reading-wise for both try and for all loop types

neogna2
Posts: 589
Joined: 15 Sep 2016, 15:44

Re: [v2] replace else-clause on loops/try with a different keyword

Post by neogna2 » 02 Mar 2023, 04:48

The use case where an else is tied to a for-loop seems very unusual so unless that pattern is simply removed I agree that the else could be renamed, maybe to forelse or fallback or otherwise or perhaps something real ugly but self-explanatory like IfNoInterations

Try-else without catch inbetween also seems very unusual. As suggested in one of the linked threads that use case could instead be handled if IfTry or Try() was added. Renaming the else is tricky here since it would be messy to have both try-catch-else-finally and try-SomeOtherName. So a new name would need to make sense in the try-catch-SomeOtherName-finally pattern too. Maybe success or OnSuccess or IfNoError or proceed

guest3456
Posts: 3462
Joined: 09 Oct 2013, 10:31

Re: [v2] replace else-clause on loops/try with a different keyword

Post by guest3456 » 25 Mar 2023, 12:48

anyway its a bug, according to the docs, 'else' can only be attached to a 'catch', not a 'try'


Post Reply

Return to “AutoHotkey Development”