I’m hoping that something like Java’s package protected construct
doesn’t ever get added to Ruby. I really don’t understand the
motivation behind it and I’d love someone to explain it to me.
It just seems like a way for programmers to try and predict what other
programmers who use their code shouldn’t do. It prevents others from
shooting themselves in the foot. We often predict incorrectly and
then other programmers are prevented from overriding the behavior they
need to override. We’re not omniscient. People often use our code in
ways we could have never predicted.
One of the things I like about Ruby is that the language seems to
allow programmers to do what they need to do without having the
constructs which prevent programmers from getting their job done. It
seems that when a language offers handcuffs, programmers use them
liberally and then other programmers constantly feel shackled.
When programming in Java, it seems I’m often thinking things like,
"Just let me override that method! Why are they preventing me from
doing that? I REALLY understand this code and I’m aware of fact that
this method is not normally overridden but this case is different."
Or, “Why can I not have some code before the super call in a
constructor?” Or, “Why did they make that variable private? I wish I
could get to that variable!”
I’ve never experienced this kind of frustration with Ruby. It’s an
incredible language. For the past few weeks, I’ve been spending half
of my day writing Ruby and half writing Java. It has been remarkable
how much less code is needed in Ruby. I’ve been amazed.
I’m definitely not an expert on Ruby scoping or access modifiers so
I’m not sure if I really understand the request for the feature. I
think I do understand Java’s package protected construct. Things are
probably very different in Ruby and I’d love someone to help me
On Tue, 2 Jul 2002 09:15:54 -0500, “Lyle Johnson” email@example.com wrote:
“Matthias Veit” firstname.lastname@example.org wrote in message
is there a possibility to gain a visibility like java’s
package protection construct:
classes in the same module (or class) can access methods,
that are not visible from outside the package.
A timely question I’m looking for something like this too. There are
certain methods that should only be visible to other classes in the same
module (package) but private outside of that package.
342 Raleigh Street
Holly Springs, NC 27540