From: Yukihiro Matsumoto Date: 2006-12-15T01:12:03+09:00 Subject: Re: Random idea - private, blocks, constants Hi, In message "Re: Random idea - private, blocks, constants" on Thu, 14 Dec 2006 05:25:11 +0900, "Daniel Berger" writes: |What do people think of the idea of private (and protected) taking a |block? | |class Foo | private do | SOME_VALUE 88 | def some_method | 7 | end | end |end | |This wouldn't really be any different than the current behavior for |methods, but it would (in theory) allow you to make constants, class |variables and class instance variables private. | |My main reason for wanting this behavior is that, in some cases, I |declare constant values that aren't meant for public use. Hmm, first we have to define how private constants (and class variables) behave. Class variables are not supposed to be accessed outside of a class body. So they are always private, I guess. We don't need special treatment for them. But how should private constants behave? Maybe making them not accessible via :: operator is suffice. I'm not sure yet. The next thing I need to think about is how we can implement them. But it's another story. As far as I can imagine now, it surely is difficult, since currently there's no place to save visibility information in the constants table. matz.