-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Proposal for Syntaxes - Function return type and Generics #1691
Comments
The The argument for |
@emlai - Thank you for the explanation. I upvoted the comment as well. |
We've been trying to avoid angle brackets because they create very serious parsing problems. For example, a correct C++ parser has to implement substantial parts of C++'s name lookup and type checking rules, because in order to parse |
I like this, it's a lot cleaner and ':' is consistent with variable declarations |
That does make sense thank you for the explanation. Lexical parsing is a bit complicated. When working with golang, that was one of the things that threw me off. I am already starting to see based on the dislikes I got... there are more developers who don't like this idea. The question is who is going to be your target users. People who come from typescript, kotlin, java, dart. Would want to use angle brackets whereas people who come from rust or go, might want to use square brackets. I'll leave it up to the discretion of the implementor. |
Existing successful successor languages, TypeScript, Kotlin, and Swift (even Rust) all use Carbon should learn from existing design and implementation work of languages with the same goal. |
Carbon has a goal of being easy to parse for tooling, which has meant that we have considered and rejected angle brackets The generics syntax is |
All syntaxes are ugly: round brackets are more intuitive for calls. The issue with the square brackets is that if Carbon aims metaprogming, at some point there are chances that square brackets become completly ambiguous with indexing on a compile time list (let's say), so if you select type N in list A, it's not visually clear if it's an instantiation or a list extraction. What should be discussed then becomes is more obvious, round or square is not the problem, the problem is to have an instantiation operator, like the bang in D, before the brackets, whatever is their shape. |
FWIW, I agree with what @josh11b has written here:
On the issue of using Marking this as an issue for leads however as it is a concrete and specific question to use two alternative syntaxes. |
Well TypeScript actually uses So |
I think there is some chance that we will want the same selection of options for function returns that we have for |
Firstly I want to say the presentation at CPPNorth was outstanding. Great work guys.
I had a couple of suggestions - I am not sure how open you are to changing the syntax styling.
Current
Proposed
<T: SomeType>
)? Square brackets are more intuitive for Arrays...The text was updated successfully, but these errors were encountered: