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 omitting parentheses around single identifier argument in function expressions. #6922

Open
lrhn opened this issue Nov 26, 2012 · 5 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). core-m type-enhancement A request for a change that isn't a bug

Comments

@lrhn
Copy link
Member

lrhn commented Nov 26, 2012

It's an edge case, but I often find myself writing
  boo.baz((foo) => using(foo))
In this case, omitting the parentheses around the parameter name would make the code easier to type, and actually easier to read in practice (in my opinion, obviously).

I.e., I suggest to allow writing
 boo.baz(foo => using(foo)).
This won't work for multiple parameters (or zero), you will need parentheses for that. It may work with a type on the parameter:
  ...(String foo => using(foo))
That's still parsable and readable.

For function declarations there is no need for this syntax, it's only for inline functions that it makes sense.

(This is apparently also used as "lambda" syntax in C# 3.0).

@gbracha
Copy link
Contributor

gbracha commented Aug 25, 2014

Set owner to @gbracha.
Added Accepted label.

@DartBot
Copy link

DartBot commented Mar 18, 2015

This comment was originally written by @bp74


As a C# developer i would love to see this feature as a DEP (Dart Enhancement Proposal).
Is there anyone here who has free time to write the proposal?
https://github.com/dart-lang/dart_enhancement_proposals

@lrhn lrhn added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Mar 18, 2015
@oliverjanik
Copy link

+1

@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
@lenkite
Copy link

lenkite commented Jan 26, 2017

Even old fashioned Java allows omitting the parenthesis around a single lambda argument

@matanlurey
Copy link
Contributor

+1 for this /cc @sethladd

@lrhn lrhn added core-m and removed P2 A bug or feature request we're likely to work on labels Dec 6, 2018
@lrhn lrhn added this to Non-Breaking And Simple in Language Enhancement Categories Dec 14, 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). core-m type-enhancement A request for a change that isn't a bug
Projects
Language Enhancement Categories
Non-Breaking And Simple
Development

No branches or pull requests

7 participants