Skip to content

Explain why Dart uses '_' for privacy rather than a keyword in the documentation. #2671

@kfish610

Description

@kfish610

Coming from C#, I was incredibly confused why Dart chose to use a prefix of _ for private variables, rather than the typical public, private, and protected modifiers. After reading through dart-lang/sdk#33383, however, I understand why Dart chose this method of visibility modification, and I don't mind it as much. However, it seems strange to me that no where in the docs does it even reference an explanation (unless I missed something, and if I did, please let me know). I think adding a section somewhere in the docs to explain the underscore notation (maybe a note in the tour?) would make people less likely to immediately discount Dart based off of this choice (I know I did, and looking at that issue, so did a lot of people).

Any opinions?

Metadata

Metadata

Assignees

Labels

a.languageRelates to the Dart language toure0-minutesCan complete in < 60 minutes of normal, not dedicated, workp2-mediumNecessary but not urgent concern. Resolve when possible.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions