Enhancement to property declaration, setters and getters syntax #11437
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
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.
The text was updated successfully, but these errors were encountered: