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

Non-const default values for static / top-level methods #3687

Closed
DartBot opened this issue Jun 15, 2012 · 6 comments
Closed

Non-const default values for static / top-level methods #3687

DartBot opened this issue Jun 15, 2012 · 6 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-obsolete Closed as the reported issue is no longer relevant P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Jun 15, 2012

This issue was originally filed by @seaneagan


It would be nice if parameter default values of static/top-level methods could be lazily initialized, probably on the first time the method is called without passing the parameter, the same way that static variables are. For example, you may want to have a parameter default value be the value of a static variable which is lazily initialized.

@sethladd
Copy link
Contributor

Removed Type-Defect label.
Added Type-Enhancement, Area-Language, Triaged labels.

@floitschG
Copy link
Contributor

This probably leads to unexpected behavior:
foo([x = new Map()]) { ... }

If we implement lazy initialization for default-values as you describe we would allocate the map only once. This is, however, completely contrary to what most programmers would expect.

@DartBot
Copy link
Author

DartBot commented Jun 19, 2012

This comment was originally written by @seaneagan


Agree. Any non-constant default value expression should be evaluated on each invocation. That would definitely be useful, and help to better document many APIs, but can probably wait until after M1.

@gbracha
Copy link
Contributor

gbracha commented Jun 26, 2012

Set owner to @gbracha.
Added this to the Later milestone.
Added Accepted label.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@DartBot DartBot added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Aug 4, 2014
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug and removed accepted labels Feb 29, 2016
@munificent munificent changed the title non-constant parameter default values for static / top-level methods Non-const default values for static / top-level methods Dec 19, 2016
@matanlurey matanlurey added the closed-obsolete Closed as the reported issue is no longer relevant label Jun 21, 2018
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-obsolete Closed as the reported issue is no longer relevant P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

7 participants