-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
try/else
proposal
#745
Comments
I am the OP, sorry for using wrong account, forgot to return to the one which is mine. |
So, following code:
Should compile to:
Separate |
|
Or, as @vendethiel suggested, just assign
|
I find this a little confusing to read (even though I understand what you're talking about). And another thing to take a look at: recent discussion to remove some of the unnecessary sugar. For what it's worth, that alone has increased skepticism for new features. |
I'm not sure if it matters, but I +1 this idea and prefer the |
@IMPinball |
@kkirby yes, |
We have |
I can't decide whether I Iike LS's |
Think of some procedure to search for config file in couple of locations, in order. It would be something like this:
And to be used like this:
But if we add a new requirement for config to fail on incorrect config files, so
new Config
can now throw if could not parse, code becomes uglier:If there was an
else
construct, it could be written like this:Which results in more compact and readable code, and works much better when there is no option to
continue
a loop. So, I propose to add optionalelse
branch totry
/catch
/else
/finally
construct, which should execute when exception didn't happen, instead ofcatch
clause and beforefinally
.The text was updated successfully, but these errors were encountered: