Issue #7519 has been updated by alexeymuranov (Alexey Muranov).


Maybe a solution would be to allow a second method table in modules, so that including a module would also add singleton methods to the base?  I suggested it for classes here: #7250, but it can without any change work for modules.  It is different from just inheriting singleton methods like in classes.

However i would see nothing wrong with inheriting any object from any other object:

x = Object.new

def x.foo
  "Foo"
end

object y < x
end

y.foo # => "Foo"

:)
----------------------------------------
Feature #7519: Module Single Inheritance
https://bugs.ruby-lang.org/issues/7519#change-34433

Author: trans (Thomas Sawyer)
Status: Rejected
Priority: Normal
Assignee: 
Category: core
Target version: Next Major


A limitation of modules is that they can not gain and augment the qualities of another module in the same manner that a class can of another class. They can use #include, but using #include to carry the behavior of one module into another is limited in that singleton methods are not available to it and also because of the well known Module Include Problem. So it occurs to me that modules could have their own inheritance chain.

For example:

  module M
    def self.foo
      "foo"
    end
    def bar
      "bar"
    end
  end

  module N < M
    def bar
      super + "!"
    end
  end

  N.foo #=> "foo"

  class C
    include N
  end

  C.new.bar  #=> "bar!"

I think it easy to think about in terms of classes being types of "nouns", and modules being types of "adjectives". So just as one "noun" can inherit the behavior of another "noun", so could one "adjective" inherit the behavior of another "adjective".



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