On Thu, Jul 3, 2014 at 12:38 PM, Jonathan S. Shapiro <[email protected]> wrote: > On Wed, Jul 2, 2014 at 4:00 PM, Matt Oliveri <[email protected]> wrote: >> You're right, I did assume that. :) I think I can even figure out a >> translation to existential types, in the style of abstract data types. >> protected fields are the part that's boogered. > > Just to clarify: do you mean this generically (protected and private fields) > or did you actually mean fields that are syntactically labeled as protected?
Syntactically labeled as protected. > Because from a programming perspective, I always felt that it was the > "private" fields that were boogered, and that in nearly all cases private > fields ought to have been protected. I'm guessing it's because you don't like the "peer access" to fields in other objects of the same class, and that protected rules that out, at least outside the package. But if you think of classes as providing an abstract data type (a la CLU or ML modules) _in addition_ to abstraction via subtype polymorphism, then private methods are just methods that are part of the abstract type implementation, but not part of the type itself. Using the class name to refer to the hidden concrete type when inside the class definition itself can be considered sugar. Similar remarks for "package private" and packages as (funky) ADTs. Package private is actually my favorite. Do you really want a trust boundary down the middle of your package? (And you can't beat 0 characters. By now you're probably positive that you don't want to write a Java program with me. ;)) Of course promiscuous reflection screws up the ADT interpretation. I already granted you that. So the reason I don't like protected is precisely because it doesn't fit into the abstract data type picture. It's like Java couldn't decide whether to be CLU with subtype polymorphism or Smalltalk with types. (Or C++ with reflection, or ML for mortals, or...) > But it's instructive to consider... > > Hmm. It's only just occurred to me that there's another possible design for > that which is probably better. I hope you were talking to yourself there, 'cause I can't tell what it has to do with this. Besides, isn't C++'s protected totally different from Java's? _______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
