From: mame@... Date: 2019-12-24T07:19:21+00:00 Subject: [ruby-core:96454] [Ruby master Bug#11878] Comparison of prepended modules Issue #11878 has been updated by mame (Yusuke Endoh). > I think no user expects that the "subclass relation" is different than the order of ancestors, isn't it? Regardless whether users know or not, they are actually different. Consider: ```ruby module M; end class C; prepend M; end class D; include M; end ``` If `M` is a subclass of `C`, `D` is a subclass of `C`. Both `A.prepend(B)` and `A.include(B)` make `A` to be a subclass of `B`. Note that the order of `Module#ancestors` is not specified; the rdoc says nothing. (IMO, `Module#prepend` is a very bad thing that makes the object system complicated.) ---------------------------------------- Bug #11878: Comparison of prepended modules https://bugs.ruby-lang.org/issues/11878#change-83379 * Author: sawa (Tsuyoshi Sawada) * Status: Open * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) * Target version: * 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: