On Mon, 13 Mar 2006, Mauricio Fernandez wrote:

> It fails in the very way matz indicated.
>
> class Module
>  def abstract_method m
>    define_method(m){|*a| raise NotImplementedError}
>  end
> end
>
> module Interface
>  abstract_method :foo
>  def bar; foo end
> end
>
> class C
>  def foo; "C#foo" end
> end
>
> class D < C
>  include Interface
> end
>
> D.new.bar
> # ~> -:3:in `foo': NotImplementedError (NotImplementedError)
> # ~> 	from -:9:in `bar'
> # ~> 	from -:20

indeed.  hmmm:

   harp:~ > cat a.rb
   class Module
     def abstract_method m
       define_method(m){|*a| super rescue raise NotImplementedError}
     end
   end
   module Interface
     abstract_method :foo
     def bar; foo end
   end
   class C
     def foo; "C#foo" end
   end
   class D < C
     include Interface
   end
   p D::new.foo


   harp:~ > ruby a.rb
   "C#foo"


though i only now thought of that - so there's probably another failing case...

probably don't want a blanket rescue for one...

regards.

-a

-- 
share your knowledge.  it's a way to achieve immortality.
- h.h. the 14th dali lama