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

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

Closed
kfish610 opened this issue Oct 2, 2020 · 8 comments · Fixed by #2681
Closed

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

kfish610 opened this issue Oct 2, 2020 · 8 comments · Fixed by #2681
Assignees
Labels
a.language Relates to the Dart language tour e0-minutes Can complete in < 60 minutes of normal, not dedicated, work p2-medium Necessary but not urgent concern. Resolve when possible.

Comments

@kfish610
Copy link
Contributor

kfish610 commented Oct 2, 2020

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?

@kwalrath kwalrath added act.wait-for-customer Needs response from customer e0-minutes Can complete in < 60 minutes of normal, not dedicated, work a.language Relates to the Dart language tour p2-medium Necessary but not urgent concern. Resolve when possible. and removed act.wait-for-customer Needs response from customer labels Oct 2, 2020
@kwalrath
Copy link
Contributor

kwalrath commented Oct 2, 2020

I don't think the language tour should justify or provide history, but it seems legit to link out to justifications (such as dart-lang/sdk#33383, in this case). Maybe a note like this:

Language note: If you're used to public and private access modifiers, see SDK issue 33383 for details on why Dart uses the _ prefix instead.

What do you think, @kfish610?

EDITED to change annotations to access modifiers.

@kfish610
Copy link
Contributor Author

kfish610 commented Oct 2, 2020

That sounds reasonable, though I think they're called access modifiers, not annotations. Other than that, seems well worded, definitely would have made me much less confused than I was when I read the tour originally.

@kwalrath
Copy link
Contributor

kwalrath commented Oct 2, 2020

Oops, yep, you're right about using access modifiers.

@kwalrath
Copy link
Contributor

kwalrath commented Oct 2, 2020

@kfish610 would you like to make this fix, or shall we open it up to the community?

@kfish610
Copy link
Contributor Author

kfish610 commented Oct 2, 2020

I can make it, is there anything I need to do other than make a pull request?

@kwalrath
Copy link
Contributor

kwalrath commented Oct 2, 2020

I can make it, is there anything I need to do other than make a pull request?

Thanks! Just make a pull request. Search for "Deprecation note" to find some code to copy. (I don't see any other "Language note"s, but it makes sense to me to have a separate note type for this.)

@kfish610
Copy link
Contributor Author

kfish610 commented Oct 2, 2020

@kwalrath Out of curiosity, is there a reason you prefer saying "Language note" as opposed to just "Note"? All of the notes on the tour just say "Note", and most of them refer to the language.

@kwalrath
Copy link
Contributor

kwalrath commented Oct 2, 2020

You're not wrong. I was thinking that a "Language note" might imply a comparison to other languages, but perhaps that's too subtle a point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a.language Relates to the Dart language tour e0-minutes Can complete in < 60 minutes of normal, not dedicated, work p2-medium Necessary but not urgent concern. Resolve when possible.
Projects
None yet
2 participants