Can you explain that? What do you mean by “don’t fit”?
I find it more convenient when the scope of the method is directly readable
from the declaration of the method. In Java, public/protected/private are
private int dontcallme();
In ruby, I need a second line to specify the scope of the method. Or the
default scope was change before the method declaration. In both cases I have
to look around the code to find what the scope of the method is.
With variables, the name only gives me all that information. It took me a
little while to get used to it (I was more used to the $ used the shell way,
to retrieve the value of the variable), I finally find it very convenient. I
was wondering if a similar concept could work with methods.
IMHO, it makes sense to demand such a prefix to save typing (although I
don’t agree with that and certainly not want that), but why should I
have to specify the “protection prefix” on method call? Do I really care
about the status of the method? The call either succeeds or fails, but
having a prefix is worthless.
As for having to write private :method instead of “private def method"
or such: you can always group private things at the end and put a single
"private clause” before. This saves even more typing
Nevertheless, I do realize that what I proposed would break many existing
code. I just threw the idea to see what people think of it, if there is a way
to make it fly. If not, I can live very well with the existing mechanism
I also notice that the ProgrammingRuby documentation, for example, doesn’t
specify which methods are plublic, protected or private. Is the scope of
methods not considered important in Ruby? On the other hand, changing the
documentation doesn’t need such a dramatich syntax change as the one I
Why would private methods be documented? They belong to the implementation
of a class, not to its interface.
As for protected, you’re only going to need it if you intend your class
to be inherited and want to expose some part of the implementation to
subclasses, which does certainly not happen in the case of the core
Inheritance is not really used a lot in Ruby, because
"it’s at best implementation sharing" (matz dixit)
On Fri, May 16, 2003 at 11:33:21PM +0900, Guillaume Marcais wrote:
On Friday 16 May 2003 03:38 am, you wrote:
__ __ | | ___ _ __ ___ __ _ _ __
’_ \ /
| __/ __| '_ _ \ / ` | ’ \
) | (| | |__ \ | | | | | (| | | | |
.__/ _,|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com
How should I know if it works? That’s what beta testers are for. I
only coded it.
– Attributed to Linus Torvalds, somewhere in a posting