-
Notifications
You must be signed in to change notification settings - Fork 208
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
Should the grammar allow ?
in an old-style function-typed formal parameter declaration?
#364
Comments
Lasse's suggestion is what I had in mind with the initial NNBD prototype back in the day. It's a little weird but, well, the function-typed parameter syntax is weird. |
I was hoping to avoid this - I think it's really hard to read. My thinking was that we would just push people to the new function type syntax, and the migration tool would just make this easier. But maybe this is too much pain, particular for manual porting of APIs. @lrhn is that your takeaway from your experiments? |
As a migrator, I would very much like to not have to rewrite my parameters. I found the I also personally prefer |
OK, I'm basically fine with this. I'll add the change to the PR in my next pass. |
Omitting support for new features is a good way to urge migration without a breaking change... |
I'd be happy to add an automated --fix to dartfmt that turns the old syntax into the new. |
There is already an assist in server (and has been since the new syntax was introduced), so we could also easily add it to dartfix. @danrubel |
And there's also the lint use_function_type_syntax_for_parameter. |
If I actually wanted to move people to the function-type syntax, then yes, this would be a way to "encourage" that move. But I don't. I actually prefer the "old" syntax for function typed parameters. I find it more readable. |
I don't dislike the old syntax, but I agree with Nate that the language would be better if there were only one syntax for expressing a function type, even if that syntax is not ideal in all cases. |
FWIW I likely would prefer the old syntax if there wasn't such a sharp edge around mistakenly adding implicitly As a general rule I also prefer if every author didn't need to make a nearly arbitrary choice between two syntaxes that achieve the same goal. |
I'm strongly for deprecating and then removing the old function literal syntax (or changing tools like typedef Formatter<T> = String func(T);
I know this isn't surprising at this point, but one person's personal opinion doesn't make a language :-/. I imagine at one point you strongly preferred dynamic/optional types, reflection over code generation, etc, but the language has to evolve to meet its users. |
I don't think @lrhn is saying that their opinion should outweigh all others, just that he is an embodiment of at least one user who does like the old syntax. Personally, I'm sympathetic because the new function type syntax isn't great either. |
Ok, I added this to the specification. If we choose to deprecate and remove this syntax I think it should be a separate effort, and the meantime it should be a first class part of the language. |
In the review of #293, @lrhn pointed out that:
I'm filing this issue to track the decision about whether we want to make this change to the grammar, so that if we do, the analyzer team can find out about it and start work.
The text was updated successfully, but these errors were encountered: