[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: About class methods visibility (public/private

Yukihiro Matsumoto

3/23/2007 8:40:00 AM

Hi,

In message "Re: About class methods visibility (public/private)"
on Fri, 23 Mar 2007 02:34:51 +0900, Ruby Admirer <ruby_admirer@yahoo.com> writes:

|In my opinion, class_private, class_public, and class_protected names have the following benefits :
|- they are very close to the private, public and protected methods.
|- they cover one or multiple arguments
|
|But similar names will also be great !

In my opinion, if you want to change the visibility, you'd better to
use singleton class notation, for class methods are singleton methods
for class objects after all.

class Foo
class <<Foo
# class method foo
def foo
end
# visibility private
private :foo
end
# instance method foo
def foo
end
# visibility private
private :foo
end

There's no need for new methods. private_class_method and others are
utility method for people who really love the term 'class methods'.

matz.

2 Answers

Trans

3/23/2007 9:34:00 AM

0



On Mar 23, 4:39 am, Yukihiro Matsumoto <m...@ruby-lang.org> wrote:

> There's no need for new methods. private_class_method and others are
> utility method for people who really love the term 'class methods'.

Ick! When did those get in there? I'm almost glad I never noticed
before. Why bother? Just give us a method for singleton/eigenclass/
metaclass whatever you want to call the "context" and allow:

context.public :foo

But if they've got to stay, please, at least consider renaming them
something like class_public and class_private.

t.


Paul Stickney

3/23/2007 11:26:00 AM

0

matz, your example was so elegantly simple that I want to say you have
my vote to just drop the methods in question--at least from core.
There is plenty of Java to go around already.