[ruby-core:32920] Re: [Ruby 1.9-Feature#3908] private constant

From: Yusuke ENDOH <mame@...>
Date: 2010-10-27 22:34:34 UTC
List: ruby-core #32920
Hi,

2010/10/27 Run Paint Run Run <redmine@ruby-lang.org>:
> Issue #3908 has been updated by Run Paint Run Run.
>
>
> I'm sorry I missed the deadline on this ticket...

No problem.  Thank you always for your detailed spec review.
# Say, I wanna work on File.write...


> 1) Is it intentional that `const_get :K`, where :K is a private constant, raises a NameError?

No.  I think `#const_get' does not raise an exception for
private constants because `#method' and `#send' does not
for private methods.

Matz, may I introduce a new method `#public_const_get', like
`#public_send'?


> 2) Should private constants be returned by `#constants`?

I think no.  I'm attaching a patch.

Matz, may I introduce two new methods, `#public_constants'
and `#private_constants'?


> 3) Is it intended that, given the name of a private constant, `#set_const` makes it public?

No.  I'm attaching a patch.


NOTES:

  - Matz is now casting doubt on this feature ;-( because
    we've not estimated the impact of this feature yet.
    Though I thought that I certainly got matz's approval,
    I might make a quick judgment.
    We're discussing still now, but this feature may be
    reverted.

  - The first patch slightly changes YARV insn format for
    defineclass, to distinguish constant access style in
    class definition, e.g.,
      OK: class Foo::PrivateClass
      NG: class PrivateClass
    Thus, ko1's approval is needed.

  - I have to work on defined?(Foo::PrivateConstant)

-- 
Yusuke Endoh <mame@tsg.ne.jp>

In This Thread