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

Get a hold of getter/setter function #13389

Closed
DartBot opened this issue Sep 18, 2013 · 5 comments
Closed

Get a hold of getter/setter function #13389

DartBot opened this issue Sep 18, 2013 · 5 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Sep 18, 2013

This issue was originally filed by Misko.H...@gmail.com


class Foo {
  String _foo;

  get foo() => _foo;

  method() => null;
}

I can closures a method like this

Function method = (new Foo()).method;

This allows me to pass the method closure into callbacks of other API. It is equally useful to pass closure for getter or setter functions. But there is no way to closures the getter/setter. The following code snippet returns a value rather then closurized function.

(new Foo()).method; // returns value rather then function closure which returns a value

Perhaps some other syntax by which I could get a hold of the getter/setter?

@lrhn
Copy link
Member

lrhn commented Sep 18, 2013

Operators too :)


Added Area-Language, Triaged labels.

@gbracha
Copy link
Contributor

gbracha commented Aug 27, 2014

 A long time ago, we proposed a uniform syntax for property extraction, that would have covered both methods, getters, setters and operators. Say o#m or o!m. People screamed they needed it to look like JS, with a dot. The fact that this would not work for getters was pointed out, but dismissed as a minor nuisance.

You can of course write

(){o.getterName} explicitly at the cost of a few more keystrokes. Similar workarounds for setters and operators.


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

@gbracha
Copy link
Contributor

gbracha commented Feb 7, 2015

Just a note that we are looking into this again.

@DartBot
Copy link
Author

DartBot commented Feb 9, 2015

This comment was originally written by @seaneagan


My objection when this was originally proposed was that it breaks the symmetry between methods and Function-valued getters. o#f would mean something different if f were a method than if it were a Function-valued getter, so refactoring between those two would be a breaking change which is unfortunate, but also not immediately obvious, so that breaking change may be unwittingly introduced.

This would make issue #2849 and issue #1616 impossible.

Also the proposed syntax e.g. o#m would be useful for issue #13056.

@DartBot DartBot added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Feb 9, 2015
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed priority-unassigned labels Feb 29, 2016
@munificent
Copy link
Member

Closing this since it asks for a feature which we added, then removed (#27518).

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). type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants