Open denisoby opened 8 years ago
Bob I can't think of a good reason why we should prohibit in named arguments. Dart visibility rules are for class members not parameter names. Prohibiting in named parameter names seems like foolish consistency particularly if Dart adopts alternative schemes for public, protected going forward.
The leading "_"
is a property of identifiers. Conceptually a leading "_"
of any identifier is replaced with a library-token. Since named arguments are parameters (and thus identifiers) they follow the same rules.
@floitschG I understand this from darts point of view. But this is conflicting with JS integration. I can't make code that works with JS that uses "_xxxx".
This looks like "we don't play football, that's our choice - thus we will not make business with people who play football".
It's more of an explanation of why this is not just that simple.
If we just went ahead and allowed named arguments with leading "_", nobody could use them. We would need to change more places in the spec (and potentially implementations) to make this work.
@floitschG thanks for explanation.
I'm trying to create query to mongodb and use nodejs library for calls to DB.
In dart I define special object to pass to nodejs api.
But building fails with error:
From my point of view this is incorrect, because JavaScript do not have this restrictions. And annotation should follow JS rules and allow using _fields.
P.S. Solution: define such fields as usual, and set them after constructor call: Example in https://github.com/dart-lang/sdk/issues/26468