On Tue, Feb 04, 2003 at 12:26:37AM +0900, Mauricio FernŠŌdez wrote:
> It turns out it is quite easy to break as it stands:
> 
> class D < A
>   class << self
>     def method_added id
>     end
>   end
>   def a; puts "I won!"; end
> end
> 
> D.new.a   # ==> "I won!"
> 
> So here's the fix:
> 
> module NoOverloading
>   def inherited << sub
	....
>     self.freeze
>   end
> end
> 
> A.freeze
> NoOverloading.freeze
> 
> this makes absolutely impossible to redefine #a, AFAIK. However, it also
> means that you can no longer create class methods.

For the record, there's a second way to break it: using alias_method
or alias. You can even remove alias_method from Module, but alias is
a keyword so there's no way to get rid of that.

-- 
 _           _                             
| |__   __ _| |_ ___ _ __ ___   __ _ _ __  
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
	Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

C:\> WIN
Bad command or filename

C:\> LOSE
Loading Microsoft Windows ...