From: ynnor@... Date: 2016-01-20T08:44:00+00:00 Subject: [ruby-core:72966] [Ruby trunk - Feature #11550] Current behaviour of super(...) is dangerous in the presence of more than one included modules. Issue #11550 has been updated by Ronald Fischer. Benoit Daloze wrote: > Ronald Fischer wrote: > > First, M1 and M2 don't know where they are going to be mixed in, so they can not invoke `suuper` - they don't know what parameters are being passed. > > > > Second, the class which mixes in M1 and M2 needs to initialize two modules, which is not possible with the current language. > > Would > > ~~~ > module M1 > def initialize(*) > super > end > end > ~~~ > > work for your use case? > Then the whole hierarchy can be initialized by just calling super. This doesn't help either. It is not a problem of the correct number of parameters, but of the semantics. Even in your design, there is no way that class C can tell to the modules M1 and M2, which parameters should be used for each respective module, UNLESS the modules cooperate in the protocol. For example, if each module allows an arbitrary list of named parameters, but picks from this list exactly the parameter which has a key (name) of the name of this module, the constructor of C could write super(M1: [3,5,8], M2: %w(foo bar)) and M1 would use the parameters 3,5,8 and M2 would use the parameters foo and bar. While this would work (and, IMHO, be even a very useful way), it would require that all modules use the same convention for parameter passing. I can do this in my own application, when I am designing my modules, but it doesn't work well when I publish a module for general use. ---------------------------------------- Feature #11550: Current behaviour of super(...) is dangerous in the presence of more than one included modules. https://bugs.ruby-lang.org/issues/11550#change-56188 * Author: Ronald Fischer * Status: Open * Priority: Normal * Assignee: ---------------------------------------- Consider a class ~~~ class C