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

Enhancement to property declaration, setters and getters syntax #11437

Closed
DartBot opened this issue Jun 21, 2013 · 3 comments
Closed

Enhancement to property declaration, setters and getters syntax #11437

DartBot opened this issue Jun 21, 2013 · 3 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-as-intended Closed as the reported issue is expected behavior type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Jun 21, 2013

This issue was originally filed by [email protected]


// Current syntax in dart
class Foo {
  // private property, scope signified by _ which is weird for many people
  // especially those coming from Java, C#, C++ etc...
  String _name;

  String get name => this._name;
         set name(v) => this._name = v;
}

Please give us this!

// Implicit public property with convenient getter/setter
class Foo {
  String name {
    set(v) { this.name = v }
    get { this.name }
  }
}

// Implicit public property with convenient getter/setter
// Magic 'value' passed in setter.
class Foo {
  String name {
    set { this.name = value }
    get { this.name }
  }
}

// Private property set with 'private' keyword rather than weird _
// preceding the property name
class Foo
{
  private String name;
}

We should adopt common practices which are good and do not be different just for the sake of being different and saving a few keystrokes.

Introduce access modifiers public, private and protected before it is too late to change the weirdness of using the presence or absence of _ to determine scope.

Dart is intended to be used by many web developers and many of those are PHP, C# and Java developers and this is what they will be expecting.

Please do not impose personal preference at the cost of familiarity on the majority of developers.

@DartBot
Copy link
Author

DartBot commented Jun 24, 2013

This comment was originally written by @butlermatt


Dup of Issue #520 ?

@DartBot
Copy link
Author

DartBot commented Jun 24, 2013

This comment was originally written by [email protected]


Set owner to @gbracha.
Removed Area-Site, Site-Tutorial, Type-Defect labels.
Added Area-Language, Type-Enhancement labels.

@gbracha
Copy link
Contributor

gbracha commented Jun 24, 2013

Reading the bug, I suspect there is a misunderstanding. The following is how things work in Dart:

// Implicit public property with convenient getter/setter
class Foo {
  String name;
}

As for the rest - Dart's privacy syntax is based on very widespread conventions use din languages like Python. It most certainly not based on personal preferences. In any case, it isn't going to change at this point.


Added AsDesigned label.

@DartBot DartBot added area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). Type-Enhancement closed-as-intended Closed as the reported issue is expected behavior labels Jun 24, 2013
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
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-as-intended Closed as the reported issue is expected behavior type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants