On 17/04/2013 11:58 AM, Brandon Mintern wrote:
Please let's not get derailed here. I wasn't bemoaning the difficulty of
implementing list iterators. I was trying to offer a simple example
everyone could understand to show when protected might be useful. There
are definitely times when implementing an interface that it's more
convenient or efficient to use an object's non-public API.

This discussion is not about list iterators, it's about whether it makes
sense to have any visibility other than public and private. I argued
that protected doesn't buy much over using unsafe private.

Yes. Our concept of visibility is a fair bit different from the way it works in other OO languages. Rust's visibility modifiers control whether one bit of code can see across a module boundary, no more.

Fields of a struct are always visible to anyone who can see the struct definition. And anyone can add methods to a struct, even outside the module it was defined in. So the whole conversation feels a bit off to me. There's no place for the concept of "protected" in the semantics at all, that I can see. It assumes a privilege-relation between certain methods and structs that doesn't exist.

-Graydon

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to