[#71931] [Ruby trunk - Feature #11786] [Open] [PATCH] micro-optimize case dispatch even harder — normalperson@...

Issue #11786 has been reported by Eric Wong.

9 messages 2015/12/08

[ruby-core:72610] [Ruby trunk - Bug #11878] Comparison of prepended modules

From: nobu@...
Date: 2015-12-30 07:36:28 UTC
List: ruby-core #72610
Issue #11878 has been updated by Nobuyoshi Nakada.


Making prepending class an ancestor of prepended module?
It feels strange a little, to me.

----------------------------------------
Bug #11878: Comparison of prepended modules
https://bugs.ruby-lang.org/issues/11878#change-55864

* Author: Tsuyoshi Sawada
* Status: Closed
* Priority: Normal
* Assignee: Nobuyoshi Nakada
* ruby -v: 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
* Backport: 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED
----------------------------------------
Including module `B` to class/module `A` gives the following results (as expected):

~~~ruby
module A; end
module B; end
A.include B
A < B # => true
B < A # => false
A <=> B # => -1
~~~

And prepending module `C` to `A` gives the following results:

~~~ruby
module C; end
A.prepend C
A < C # => true
C < A # => nil
A <=> C # => -1
~~~

It looks like including and prepending almost do not make difference with respect to module comparison, i.e., `A < B` and `A < C` are the same, and `A <=> B` and `A <=> C` are the same. However, then, the difference between `B < A` and `C < A` stands out unexplained. I suppose this is a bug. If `C < A` were to return `false`, then it would be at least consistent.

However, if that was what was intended, then at least to me, it is strange. In that case, I would like to make this a feature request. I would rather expect:

~~~ruby
A < C # => false
C < A # => true
A <=> C # => 1
~~~




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

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next