Replies: 13 comments
-
I'm a huge fan of |
Beta Was this translation helpful? Give feedback.
-
@Vlad-Stryapko It should probably be something like this:
But honestly, the following looks much better:
I can't see the benefit of having the arrow there but maybe for something like this:
Again, don't think it looks that good and we go back to the point of making swallowing exceptions easier, this topic was discussed to death though. |
Beta Was this translation helpful? Give feedback.
-
What about try =>
try => DoSomething()
catch (FooException e) => HandleFooException(e)
catch (BarException e) => HandleBarException(e) // where do I belong?
catch (BazException e) => HandleBazException(e) // where do I belong?
finally => CleanUp() // where do I belong? Also, your proposal title is "Allow => everywhere" but you only touch on |
Beta Was this translation helpful? Give feedback.
-
@HaloFour Well, by disallowing nested exception you avoid the issue completely so in my opinion it make sense to disallow it. Alternatively:
|
Beta Was this translation helpful? Give feedback.
-
The point in here is to make code more readable, if we can make it from {} to => and from => to not having anything at all as @eyalsk suggests |
Beta Was this translation helpful? Give feedback.
-
try is not an expression, I suppose the grammar is |
Beta Was this translation helpful? Give feedback.
-
The problem with this is that => means one of two things depending on context. It either means With statement forms, it isn't clear. if i have: int Foo()
{
try => Bar();
catch => Baz();
return Quux();
} Does that mean: int Foo()
{
try { return Bar(); }
catch { return Baz(); }
return Quux();
} or int Foo()
{
try { Bar(); }
catch { Baz(); }
return Quux();
} ? |
Beta Was this translation helpful? Give feedback.
-
Well at the end of the day it saved only two characters. |
Beta Was this translation helpful? Give feedback.
-
One. |
Beta Was this translation helpful? Give feedback.
-
The only proposal that I really want that yes, saves on characters and nesting is the namespace one but most of these niche proposals just don't cut it for me and probably for many of us. p.s. Just think of the times you have to catch an exception and even more so the time you spend calling a single method in a try/catch block, does this really worth a language change? or anything? |
Beta Was this translation helpful? Give feedback.
-
I suggest following pattern Foo() catch (IOException) Debug.WriteLine("error"); This pattern is restricted to only one catch. |
Beta Was this translation helpful? Give feedback.
-
I'm not so sure that swallowing exceptions should be made easier... |
Beta Was this translation helpful? Give feedback.
-
@banjouuid This is useful only if int a = try int.Parse(input) catch 0; |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It could be nice to have:
try => FilePicker.Open(file); catch=> Debug.WriteLine("error");
Rather than:
try { FilePicker.Open(file); } catch { Debug.WriteLine("error"); }
Let me know what you think.
Beta Was this translation helpful? Give feedback.
All reactions