From: Ricky Ng Date: 2013-01-20T05:07:39+09:00 Subject: Re: Module including other module. --bcaec55556b00f752304d3a9ac6b Content-Type: text/plain; charset=ISO-8859-1 Ahh, that makes sense! Thanks Xavier! On Sat, Jan 19, 2013 at 3:52 AM, Xavier Noria wrote: > I asked about this to Matz in the past and it works that way basically as > a consequence of the implementation. >> >> > As you probably know, MRI stores a linear flat chain of ancestors of > a class or module. Each ancestor has a pointer to its own direct ancestor > in the chain of that particular class or module conceptually (there are > indirections but they are not important). > > Thing is, albeit new methods are found because method name resolution > follows the pointers at the time of the call (conceptually), and albeit if > you include another module in the very class the pointers are > adjusted, when you include a 2nd order module the ancestor chains of the > classes or modules the enclosing module was already mixed in are not > updated and reflattened so to speak. > > Indeed, modules just do not keep that information, they do not know where > they have been included. So that update is not even possible with the > current implementation. > > Matz said he would be willing to make this work provided the > implementation had no performance penalty. > > Sent from my iPhone > -- Incoherently, Ricky Ng --bcaec55556b00f752304d3a9ac6b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Ahh, that makes sense! Thanks Xavier!

=


On Sat, Jan 1= 9, 2013 at 3:52 AM, Xavier Noria <fxn@hashref.com> wrote:
I asked about this to Matz in the past and i= t works that way basically as a consequence of the implementation.

As you probably know, MRI stores=A0a linea= r flat chain of ancestors of a=A0class or module. Each ancestor has a point= er to its own direct ancestor in the chain of that particular class or modu= le conceptually (there are indirections but they are not important).

Thing is, albeit new methods are found because method n= ame resolution follows the pointers at the time of the call (conceptually),= and albeit if you include another module in the very class=A0the pointers = are adjusted,=A0when you include a 2nd order module the ancestor chains of = the classes or modules the enclosing module was already mixed in are not up= dated and reflattened so to speak.

Indeed, modules just do not keep that information, they= do not know where they have been included. So that update is not even poss= ible with the current implementation.

Matz said he= would be=A0willing to make this work provided the implementation had no pe= rformance penalty.

Sent from my iPhone



--
Incoherently= ,
Ricky Ng
--bcaec55556b00f752304d3a9ac6b--