From: "headius (Charles Nutter)" <headius@...>
Date: 2012-10-13T14:01:37+09:00
Subject: [ruby-core:47957] [ruby-trunk - Bug #7152] Is the order of Module#instance_methods intended to be preserved?


Issue #7152 has been updated by headius (Charles Nutter).


I vote no! Imposing order upon the method table requires all implementations to use an ordered data structure here where unordered structures might serve better. Also consider that reflective method access on most other platforms does not guarantee any ordering.
----------------------------------------
Bug #7152: Is the order of Module#instance_methods intended to be preserved?
https://bugs.ruby-lang.org/issues/7152#change-30520

Author: hasari (Hiro Asari)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-darwin12.2.0]


https://github.com/jruby/jruby/issues/277 asks this question:

results = 10000.times.map do
  chars = ('A'..'Z').map(&:to_sym).shuffle

  cls = Class.new do

    chars.each do |chr|
      define_method(chr) {}
    end

  end

  chars == cls.instance_methods.take(26)
end

p results.all?{|o|o.equal? true} # => true on MRI


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