Cannot override #== with mixin, was help with patch to ruby-

Hi all

I have sent a little patch, defining HalfOrder, to ruby-core in order to
get
some help with a problem I have found. Maybe this was not the best
procedure.
So I’ll try here again :frowning:

basically the patch defines a module HalfOrder which defines “>”, “>=”,
“<”
and “==” depending on “<=”, well almost because a potential #== in the
Mixer
class, as in Set cannot be overwritten. I think this is a shame.
Here goes some code expressed in ruby instead of C

module HalfOrder

Mixer has to define #<=


def == other

in case of performance problems you might want to define ==

yourself
self <= other && other <= self
end

end

class Set
include HalfOrder
end

Set.new == Set.new # works while it should raise a NoMethodError for a
missing #<=

well should as in I would like.

Any ideas? ( Maybe the HalfOrder module should complain or warn when
mixed
into a Class already containing a #==; guess I do not know how to do
that in
C, yet)

Cheers
Robert

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all progress
depends on the unreasonable man.

  • George Bernard Shaw