Skip to content
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

Allow required parameters to be named #3302

Closed
DartBot opened this issue May 29, 2012 · 8 comments
Closed

Allow required parameters to be named #3302

DartBot opened this issue May 29, 2012 · 8 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented May 29, 2012

This issue was originally filed by [email protected]


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.

@madsager
Copy link
Contributor

Added Area-Language, Triaged labels.

@peter-ahe-google
Copy link
Contributor

@gbracha
Copy link
Contributor

gbracha commented Jun 2, 2012

Set owner to @gbracha.
Removed Type-Defect label.
Added Type-Enhancement, Accepted labels.

@gbracha
Copy link
Contributor

gbracha commented Jun 8, 2012

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.

@DartBot
Copy link
Author

DartBot commented Nov 2, 2012

This comment was originally written by [email protected]


I know this issue is WontFix but any update on the mentioned proposal to separate optional and named parameters?

@DartBot
Copy link
Author

DartBot commented Nov 8, 2012

@DartBot
Copy link
Author

DartBot commented Nov 8, 2012

This comment was originally written by [email protected]


"Named optional params and positional optional params"
but not
"Named required params"
if I understand it properly.

@DartBot
Copy link
Author

DartBot commented Nov 8, 2012

This comment was originally written by [email protected]


Oh, sorry. You were referring to the location of the proposal. My mistake. Thanks for that.

@DartBot DartBot added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Nov 8, 2012
@kevmoo kevmoo added closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug and removed resolution-wont_fix labels Mar 1, 2016
copybara-service bot pushed a commit that referenced this issue Jan 19, 2023
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 <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants