Hi all,

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.

A good example is the windows-pr stuff, where I'm converting C macros
to Ruby values, or using constants to store function pointers from
Win32API.  If you were to do 'require "win32/file"', and then print the
results of File.constants, you would see dozens of constants, e.g
File::INVALID_HANDLE_VALUE, File::DeviceIoControl, etc.  Most of those
are not meant for public use and should not be visible directly by the
end user.

Come to think of it, perhaps we don't need the block.  Just declare
that anything declared after 'private' is private, including constants,
etc.

Or is this concept just too radical?

Regards,

Dan

PS - I thought this had been brought up in the past, but I couldn't
find anything.