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

Feature idea: enum paramters shouldn't require enum name prefix. #39790

Closed
yahel-ck opened this issue Dec 13, 2019 · 1 comment
Closed

Feature idea: enum paramters shouldn't require enum name prefix. #39790

yahel-ck opened this issue Dec 13, 2019 · 1 comment

Comments

@yahel-ck
Copy link

  • Dart SDK Version 2.7.0

Rationale

Since the expected type of function parameters is already clearly defined and known (especially with named parameters), having to specify it when passing an enum identifier (EnumType.identifier) is quite redunant. This feature can further optimize Dart for UI by making passing widget attributes shorter and more readable.

Examle

Instead of:

Column(
  mainAxisAlignment: MainAxisAlignment.center,
  ...
)

You'd write:

Column(
  mainAxisAlignment: center,
  ...
)

To emphasize: all of the enum's instances will be available in the 'scope' of that one parameter, as if the current piece of code is contained inside the actual defenition of the enum class. This design also resolves possible name shadowing issues created by this feature; i.e. if a variable with the same name as one of the enum identifiers exists in the current scope, you could only access that identifier by refrencing the enum's name the normal way.

@yahel-ck yahel-ck changed the title Feature idea: enum paramters to not require class name prefix. Feature idea: enum paramters should'nt require class name prefix. Dec 13, 2019
@yahel-ck yahel-ck changed the title Feature idea: enum paramters should'nt require class name prefix. Feature idea: enum paramters shouldn't require class name prefix. Dec 13, 2019
@yahel-ck yahel-ck changed the title Feature idea: enum paramters shouldn't require class name prefix. Feature idea: enum paramters shouldn't require enum name prefix. Dec 13, 2019
@simolus3
Copy link
Contributor

I think this is a duplicate of dart-lang/language#357

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants