The returned
keyword
#1889
jarzec
started this conversation in
Language design
Replies: 1 comment 1 reply
-
The original proposal discusses this alternative here. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I very much like the idea of the "explicit NRVO" proposed for Carbon. I am a big fan of "expicit over implicit". However, I personally find the syntax a bit verbose in simple cases. I think in such cases it could be replaced with the familar prameter declaration syntax for declaring a named return variable.
To show better what I mean let me transform the example from the design page:
The proposed variant would be:
I understood that the
returned var
syntax was intended to allow for limiting the scope of the returned variable. Nevertheless, I still think that in many simple cases just being able to name the return variable as shown above would make the code nicer to read.The proposed variant would be just syntactic sugar for defining a
returned var
at function scope, so I don't think it would add any new issues.What do you think? I am no programming language expert but I would be more than happy to help implement this proposition to learn how to contribute.
Beta Was this translation helpful? Give feedback.
All reactions