Issue #8497 has been reported by kou (Kouhei Sutou).

----------------------------------------
Feature #8497: private, protected, private_const?????????????????????????????????????????
https://bugs.ruby-lang.org/issues/8497

Author: kou (Kouhei Sutou)
Status: Open
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: 


RubyKaigi 2013????????障?ゃ???????????荅??????????????????宴???????????障?????

???????罅??????吾????障?????

private, protected, private_const???????с??紊???眼???????<?純??????????????????????????????????????????????????????????????????с??紊???眼???????????????????????????

箴?:
  private do
    def some_private_method
    end
  end

  def some_public_method
  end

  private_const do
    PRIVATE_CONSTANT = true
  end

??<????????篁ヤ???????????с?????

  * 篁ヤ?????????????????????????2?????吾??荀????????

      PRIVATE_CONSTANT = true
      private_const :PRIVATE_CONSTANT

  * ?????у????眼?綵??帥?????????????????????????????絎?茖??????с?????
    鐚??????с?????????????????????????????????c?????????с??緇???с???????莢??c???????????????鐚?

  * 罕???????≪??????障?ゃ?????????????????????????????????????c??????
    ??????????????篏帥?c??罕???????????????????????????????????????荅?????帥???????腟????????????????????????????

?????<????????篁ヤ???????????с?????

  * ?????剛???????с????

    ???Ruby??т札筝???????????吾???????????????????∴??????????<?純????????絎?臂????????????

      private do
        def some_private_method
        end
      end

??????с?????

private??篁ヤ?????????????潟?潟?????鴻????????с??紊???眼?????

  private
  def xxx
  end

?????????吾????鴻????с?????????private_constant???

  private_constant :XXX

?????????吾????鴻???????с???????????????????c?????????????с???????????宴???????????帥?障????????

?????宴?????潟?潟?????鴻????????с??紊???眼????????<????????????絎?茖????????????紊у????????????????????荅?????????????????Thread???篏帥?c??????????筝茵????require????????????????????????????????????????????????????????????????????????????????<?????????????????????緇???????????????????????????????????????????с????????

荅????????c??帥?障???????????????????????障???????с????????

threaded-require.rb:
  100.times do |i|
    File.open("#{i}.rb", "w") do |rb|
      rb.puts("class A")
      rb.puts("  " + ["private", "protected", "public"][i % 3])
      rb.puts("  Thread.pass")
      rb.puts("  def x#{'%02d' % i}; end; Thread.pass")
      rb.puts("end")
    end
  end

  threads = []
  50.times do |i|
    threads << Thread.new(i) do |j|
      require_relative("#{j}")
    end
  end
  threads.each(&:join)

  class A
    p [:private, private_instance_methods(false).sort]
    p [:public, public_instance_methods(false).sort]
    p [:protected, protected_instance_methods(false).sort]
  end

絎?茵?箴?鐚?罸????????鐚?:
  % /tmp/local/bin/ruby -v threaded-require.rb
  ruby 2.1.0dev (2013-06-05 trunk 41090) [x86_64-linux]
  [:private, [:x00, :x03, :x06, :x09, :x12, :x15, :x18, :x21, :x24, :x27, :x30, :x33, :x36, :x39, :x42, :x45, :x48]]
  [:public, [:x02, :x05, :x08, :x11, :x14, :x17, :x20, :x23, :x26, :x29, :x32, :x35, :x38, :x41, :x44, :x47]]
  [:protected, [:x01, :x04, :x07, :x10, :x13, :x16, :x19, :x22, :x25, :x28, :x31, :x34, :x37, :x40, :x43, :x46, :x49]]

????????蚊??や札筝??????????綣桁????????荅?????帥?????????????c?<???茵???????罸?????????紊????????障????????鐚??????????????????c??????????????????????????????????????????羂?????????障?????鐚?

thread-def.rb
  class A
    threads = []
    100.times do |i|
      threads << Thread.new(i) do |j|
        send([:private, :protected, :public][j % 3])
        Thread.pass
      end
    end
    Thread.pass
    def a; end; Thread.pass
    def b; end; Thread.pass
    def c; end; Thread.pass
    def d; end; Thread.pass
    def e; end; Thread.pass
    def f; end; Thread.pass
    def g; end; Thread.pass
    def h; end; Thread.pass
    def i; end; Thread.pass
    def j; end; Thread.pass
    def k; end; Thread.pass
    def l; end; Thread.pass
    def m; end; Thread.pass
    def n; end; Thread.pass
    def o; end; Thread.pass
    def p; end; Thread.pass
    def q; end; Thread.pass
    def r; end; Thread.pass
    def s; end; Thread.pass
    def t; end; Thread.pass
    def u; end; Thread.pass
    def v; end; Thread.pass
    def w; end; Thread.pass
    def x; end; Thread.pass
    def y; end; Thread.pass
    def z; end; Thread.pass
    threads.each(&:join)
    p [:private, private_instance_methods(false)]
    p [:public, public_instance_methods(false)]
    p [:protected, protected_instance_methods(false)]
  end

絎?茵?箴?1:
  % /tmp/local/bin/ruby -v thread-def.rb
  ruby 2.1.0dev (2013-06-05 trunk 41090) [x86_64-linux]
  [:private, [:b, :c, :d, :e, :f, :g, :h, :i, :j, :k, :l, :m, :n, :o, :p, :q, :r, :s, :t, :u, :v, :w, :x, :y, :z]]
  [:public, [:a]]
  [:protected, []]

絎?茵?箴?2鐚?絎?茵?箴?1???????????????c??????鐚?:
  % /tmp/local/bin/ruby -v thread-def.rb
  ruby 2.1.0dev (2013-06-05 trunk 41090) [x86_64-linux]
  [:private, []]
  [:public, [:a, :b]]
  [:protected, [:c, :d, :e, :f, :g, :h, :i, :j, :k, :l, :m, :n, :o, :p, :q, :r, :s, :t, :u, :v, :w, :x, :y, :z]]

???????????篏帥?c????吾????鴻????泣????若????????????筝?????????????????????<???????????????????????絎?茖????с????????????????????????с??????????篏帥?c????吾????鴻????泣????若????????????????с???????????鐚?

鐚??????<??????????????????????<???????羆????????????????????????????????障??????????????鐚?

???????????篏帥???????????????c???筝?????????????????????<??????????????????????茖??????c????????篁ヤ?????潟?若?????罸????????腟???????????????с?????

  File.open("thread-block-def.rb", "w") do |rb|
    rb.puts("class A")
    rb.puts("  threads = []")
    100.times do |i|
      rb.puts("  threads = Thread.new do")
      visibility = ["private", "protected", "public"][i % 3]
      rb.puts("    #{visibility} do")
      ("a".."z").each do |character|
        rb.puts("      Thread.pass")
        rb.puts("      def #{character}#{'%02d' % i}")
        rb.puts("      end")
        rb.puts("      Thread.pass")
      end
      rb.puts("    end")
      rb.puts("  end")
    end
    rb.puts("threads.join(&:each)")
    rb.puts("end")
  end

  require_relative("thread-block-def")

  class A
    p [:private, private_instance_methods(false).sort]
    p [:public, public_instance_methods(false).sort]
    p [:protected, protected_instance_methods(false).sort]
  end



-- 
http://bugs.ruby-lang.org/