You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The identifier -> used to indicate that the return type follows.
But even ignore it, we and compiler also can know ) follows is return type.
The identifier -> has no meaning, it is only a convention said that follows return type. So we also can convention (args) follows return type, -> increases the burden on us and the compiler.
Let's consider function syntax as this:
funcname(args)return-type{ }
Now, let's consider the case where the exception description is included.
I suggestion the syntax like this:
funcname(args)return-typethrowexception-type{ }
As you see, -> is not necessary, we don't need it to indicate that the return type follows. As long as we agree that the parameter is followed by the return type.
In the long-term generic practice of C++, the post-return type is good, not only simplifies the writing, but also in the template function the return type often depends on the parameter type. So, carbon uses this syntax I feel very happy. If can remove -> is better.
The text was updated successfully, but these errors were encountered:
The function declaration syntax was considered and decided in #438.
There are of course a very wide variety of syntaxes that we might consider and that would be workable in theory.
However, beyond any aesthetic desire to have an unambiguous marker that a return type follows the parameter list, there is the simple fact that C++ uses this exact syntax for its trailing return types, as do both Swift and Rust. I think the consistency alone makes an extremely strong argument for the syntax we have.
Unless there is a significant signal of new interest from the community in revisiting this (can use reaction emojis for example), or a specific articulated problem with this syntax (as opposed to feeling like it is unnecessary), I don't think this is something we should revisit at this point. Closing as "not planned", but happy to reopen if anyone thinks there is important signal that the leads should reconsider this.
The identifier
->
used to indicate that the return type follows.But even ignore it, we and compiler also can know
)
follows is return type.The identifier
->
has no meaning, it is only a convention said that follows return type. So we also can convention(args)
follows return type,->
increases the burden on us and the compiler.Let's consider function syntax as this:
func
name(
args)
return-type{ }
Now, let's consider the case where the exception description is included.
I suggestion the syntax like this:
func
name(
args)
return-typethrow
exception-type{ }
As you see,
->
is not necessary, we don't need it to indicate that the return type follows. As long as we agree that the parameter is followed by the return type.In the long-term generic practice of C++, the post-return type is good, not only simplifies the writing, but also in the template function the return type often depends on the parameter type. So, carbon uses this syntax I feel very happy. If can remove
->
is better.The text was updated successfully, but these errors were encountered: