Reputation: 303
Slide 33 of that presentation of optional typing (by Bracha) presents common constructs that should be precluded by optional typing, like public fields or class-based encapsulation. However, doesn't Dart have those constructs although it is is said to support optional typing?
Upvotes: 1
Views: 52
Reputation: 21383
Dart actually has neither of those constructs.
While it may look like Dart has public fields, in actuality implicit getters and setters are generated for each field, so that you are not accessing the field directly.
As far as class-based encapsulation, Dart has no such concept. Instead encapsulation is accomplished through the use of libraries. All classes that are part of a library may access private members of other classes in that library, while classes from a different library can not.
Upvotes: 3