-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Allow required parameters to be named #3302
Comments
Added Area-Language, Triaged labels. |
Set owner to @gbracha. |
We are looking at separating optional parameters from named parameters, but a bit differently. I hope to have a proposal in th enot-too-distant future. Added WontFix label. |
This comment was originally written by colm...@gmail.com I know this issue is WontFix but any update on the mentioned proposal to separate optional and named parameters? |
This comment was originally written by dnlj...@gmail.com It was in milestone 1, see http://www.dartlang.org/articles/m1-language-changes/#named-optional-params-and-positional-optional-params-are-specified-differently |
This comment was originally written by colms...@gmail.com "Named optional params and positional optional params" |
This comment was originally written by colms...@gmail.com Oh, sorry. You were referring to the location of the proposal. My mistake. Thanks for that. |
Revisions updated by `dart tools/rev_sdk_deps.dart`. dartdoc (https://github.com/dart-lang/dartdoc/compare/a99abd4..ed56883): ed56883d 2023-01-17 Parker Lougheed Fix, cleanup, and simplify CSS (#3302) http (https://github.com/dart-lang/http/compare/c955c7e..57c53b0): 57c53b0 2023-01-17 Brian Quinlan Fix a NPE that occurs when an error occurs before a response is received. (#852) protobuf (https://github.com/dart-lang/protobuf/compare/dd04535..cc0f287): cc0f287 2023-01-18 Kevin Moore Run non-null-safe tests with Dart 2 (#791) test (https://github.com/dart-lang/test/compare/43fd928..19582a8): 19582a8d 2023-01-19 Nate Bosch Avoid empty `::group::` in Github reporter (#1855) fc4ea341 2023-01-19 Nate Bosch Fix a test to use an still invalid URI (#1856) bd96213a 2023-01-18 Nate Bosch Improve output for collections and long strings (#1852) 9f7de8a2 2023-01-17 Nate Bosch Remove operator extensions (#1847) f790feb0 2023-01-17 Nate Bosch Add Condition abstraction (#1846) webdriver (https://github.com/google/webdriver.dart/compare/b8c7bb5..00c887d): 00c887d 2023-01-17 Devon Carew rev to 3.0.2 in preparation for publishing (#268) Change-Id: I2cbbcdce4fa510cd2458aa05dd45eed01e840c9c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279329 Auto-Submit: Devon Carew <devoncarew@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This issue was originally filed by sammcca...@google.com
I'd like to be able to optionally name required parameters at the callsite. (I'd still have to get the position right).
So with
void move(int x, int y);
these are equivalent:
move(x:4, y:2);
move(4, 2);
move(4, y:2);
and these are errors
move(x:4);
move(y:4, x:2);
The main reasons are consistency, readability, and safety.
* optional parameters names are part of the API, but required parameters are not.
* optional parameters can be named to increase readability, but required parameters cannot:
Car(wheels, seats, [doors=4]);
var sportsCar = new Car(4, 4, 2); // Hard to read
var van = new Car(4, 8, doors: 3); // Better, but weird
var truck = new Car(wheels:12, seats:2, doors: 2); // Clearest
* naming required parameters gives the runtime more information to warn about errors. e.g. accidentally switching the parameter order above will silently do the wrong thing, but if I named the parameters then the compiler would catch the error.
The text was updated successfully, but these errors were encountered: