On Jun 24, 6:48=A0am, Robert Klemme <shortcut... / googlemail.com> wrote:

> I believe the more important point is that - although classes and
> modules have only few differences (inheritance, instance creation) -
> they are deliberately kept separate because they are language
> artifacts intended to model different concepts (entities vs.
> behavior). =A0Even if it is technically possible to mix in classes the
> same way as modules (and I believe J=F6rg's assessment is correct here)
> it probably does not make much sense to allow this from a conceptual
> point of view.

I disagree. This sort of explanation has no material bases --how does
the conceptual distinction help us? I think it hurts us for a few
reasons.

1) It disrupts auto-creation of namespaces. E.g.

  class Y::X
  end

What is Y, a class or module? Because of the distinction between class
and module you have to pre-define it. This futher leads to "bottom
requiring" --using require at the bottom of scripts instead of at the
top.

2) The developer is forced to choose between two arbitrarily limited
mechanisms for modeling behavior. Classes can only re-used once per
subclass and not at all via modules. Modules can be reused extensively
but do not naturally include their singleton methods. These
limitations lead to a number of code smells from overly limited use of
inheritance to included/ClassMethods hooks.

3) Using tools for conceptually different cases does not require that
their be physically different tools for each case. I wrench is just as
good for tightening a nut as it is for loosening one. If I had to use
two separate tools it would be quite annoying.

Following your conceptual distinction argument we could just as easily
argue for separate entities for mixins and namespaces  since those are
also different uses of modules. Clearly no one wants that.

I have never heard of a solid reason for the division between classes
and modules --my guess is that there is no real reason other than that
it how it was done originally, and changing it now means 1) a major
version bump and 2) an overhaul of the implementation.