From: Xavier Noria Date: 2011-04-13T16:20:23+09:00 Subject: [ruby-core:35733] Re: caching of the ancestor chain What's the downside of the naive implementation? Each class has two slots: list of pointers to direct mixins (no flat list, only the direct ones that were mixed in and in the correct order) and a pointer to the parent class. Modules have a slot with the list of direct mixins. Method dispatch loops/recurses. We ask each mixin in turn whether he responds to the method. At that point of execution, mixins ask themselves, and if not loop over their direct mixins. Recurse. If all of them fail, I go to the parent class and repeat. Of course the complete algorithm would include method_missing, singleton classes... but just to give the idea. I have NO experience writing interpreters, is that a terrible implementation? The number of pointers to follow seems to be about the same more or less doesn't it... if it is bad why is it bad? Not proposing anything of course (I can't propose anything I have no ida about VMs :), only doing this as an exercise to try to understand why it works the way it works.