From: Robert Dober Date: 2008-09-02T19:22:03+09:00 Subject: Re: Undo Object.extend On Mon, Sep 1, 2008 at 10:34 PM, José Ignacio wrote: > Thanks, that's a really nice piece of code that helps a lot :) > > Why use a @__bsp__ variable instead of using @__behavior_stack__.pop or > @__behavior_stack__.last ? Good question ;). Actually I am leaving empty modules on the stack that can be reused, thus after a push_behavior the stack might look like this [ x, module with the methods from pushed behavior ] and the sp is 1 after pop_behavior the situation is as follows stack : [x, empty module] and the sp=0. This avoids unnecessary recreation of modules ( and lets the GC rest, but that was not the idea ;) > > It seems that the trick to undo Object.extend is done by erasing all > instance methods in the modules. Isn't this a bit strange? If Ruby > allows including modules in an instance's ancestor chain, there should > be a way to remove them... I am not sure to understand this question, do you mean removing them from the includee? That would not work, sorry if I miss the obvious here maybe you might elaborate. Cheers Robert > -- > Posted via http://www.ruby-forum.com/. > > -- C'est véritablement utile puisque c'est joli. Antoine de Saint Exupéry