-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Champion "Mix Declarations and Variables in Deconstruction" #125
Comments
This feature would clean up code that propagates statuses and errors via tuples, similar to error handling in Go. For example: Err err;
Ret1 ret1;
(ret1, err) = await Func1();
if (err) return (default, err);
Ret2 ret2;
(ret2, err) = await Func1();
if (err) return (default, err); Could turn into: Err err;
(var ret1, err) = await Func1();
if (err) return (default, err);
(var ret2, err) = await Func1();
if (err) return (default, err); Which is much easier to read IMO. |
Unless there are good technical reasons not to, this definitely should be implemented, it is just natural. |
Linking #3304 here since I believe they belong to the same bucket - would be a nice-to-have syntax relaxation for the deconstruction feature. (var sum, count: someExistingLocation) = e; |
This was merged under LangVersion=Preview as part of VS 16.10. Thanks @YairHalberstadt for the contribution! |
See
The text was updated successfully, but these errors were encountered: