>>>>> "R" == Raja S <raja / cs.indiana.edu> writes:

R>          alias old_new Hash.new

 If you give this syntax you give also the possibility to write :

            alias Hash.new Array.new

 and many stupid things like this.

R>     we are aliasing 'new' which in this context is an -instance- method of the
R>     anonymous class being created.

 No, ruby don't create an anonymous class

pigeon% cat b.rb
#!/usr/bin/ruby
class A
   def A.new
      p "A::new"
   end
   class << self
      def new
         super
      end
   end
end
 
A.new
pigeon% 

pigeon% b.rb
pigeon% 

 If an anonymous class is created, ruby has the possibility to call the
  old method A::new and print "A::new". This is not the case, the new method
  A::new (which call #super) override the previous definition.

 You have an anonymous class in this case

pigeon% cat b.rb
#!/usr/bin/ruby
class A
   def toto
      puts "toto #{id}"
   end
end
 
a = A.new
class << a
   def toto
      super
      puts "tutu #{id}"
   end
end
 
b = A.new
 
a.toto
b.toto
 
pigeon% b.rb
toto 537709366
tutu 537709366
toto 537709336
pigeon% 


Guy Decoux