Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Superclass of eigenclass in 1.8.6

Reply
Thread Tools

Superclass of eigenclass in 1.8.6

 
 
Paolo Nusco Perrotta
Guest
Posts: n/a
 
      04-16-2007
Test script:

class Object
# good old eigenclass accessor
def eigenclass; class << self; self; end; end
end

class A; end
class B < A; end
b = B.new

p "super of eigen of b: #{b.eigenclass.superclass}"
p "super of eigen of B: #{B.eigenclass.superclass}"
p "super of eigen of A: #{A.eigenclass.superclass}"

Ruby 1.8.2 and Ruby 1.9 give the same result:

MacNusco:/usr/bin nusco$ ruby -v /strange.rb
ruby 1.8.2 (2004-12-25) [universal-darwin8.0]
"super of eigen of b: B"
"super of eigen of B: #<Class:A>"
"super of eigen of A: #<Class:Object>"

This is what I expected, and consistent with the way method lookup
works for singleton methods in both objects and classes. On the other
hand, Ruby 1.8.5 and 1.8.6 surprised me:

MacNusco:/ nusco$ ruby -v /strange.rb
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.9.1]
"super of eigen of b: #<Class:B>"
"super of eigen of B: #<Class:Class>"
"super of eigen of A: #<Class:Class>"

What the heck?


Paolo Perrotta
Bologna, Italy

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Superclass of eigenclass Danny O cuiv Ruby 29 05-20-2009 08:30 PM
How to check if another object is my superclass from a function in aneven higher superclass? bart van deenen C++ 6 03-03-2009 02:44 PM
calling superclass __init__ when superclass is object Evan Klitzke Python 0 08-02-2007 05:15 AM
Defining Eigenclass Matt Todd Ruby 20 08-13-2006 04:57 AM
Alternate notation for eigenclass Trans Ruby 19 03-15-2006 02:09 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57