Page 1 of 1

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

Posted: 28 Feb 2023, 16:49
by swagfag

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

Posted: 01 Mar 2023, 16:08
by iseahound
continue? Else works fine here semantically speaking, but does interfere with the if-else construct.

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

Posted: 01 Mar 2023, 18:30
by swagfag
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

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

Posted: 02 Mar 2023, 04:48
by neogna2
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

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

Posted: 25 Mar 2023, 12:48
by guest3456
anyway its a bug, according to the docs, 'else' can only be attached to a 'catch', not a 'try'