From: Logan Capaldo Date: 2006-10-04T11:35:03+09:00 Subject: Re: dynamically changing superclass/mixins On Tue, Oct 03, 2006 at 07:10:10PM +0900, Michael Keller wrote: > I have strong interest in highly dynamic languages, particularly > prototype-based languages - and am still looking for the language that I > have to "abuse least" to achieve what I want (for my attempt in Java, This may be considered blashpemous, but have you seen Io? (http://www.iolanguage.com) It lets you alter the prototypes for an object dynamic, which effectively gives you the abilities of removing mixins and changing the superclass. > see http://diamondmud.sourceforge.net/, particularly > http://diamondmud.sourceforge.net/architecture.html) > > Ruby, apart from just being a great language, has two features that are > fantastic for me: > - open classes: I can add and remove methods "at runtime" > - mixins; this is highly reminiscient of prototype based languages anyway. > > Now I have two questions: > > 1. Can I change the superclass for an already defined class? That is, > remove an existing relationship or add a new one? I haven't been able to > figure that out. > > 2. Can I also remove modules that I included into a class? I have only > found a very ugly way to do this: undefine the class (Klass = nil) and > define it anew. I am not sure even, what the effect was on existing > instances; if they adapted the new behaviour or not. > Setting the constant to nil will not effect existing instances. > I am fairly new to Ruby, so please forgive fundamental misunderstandings!