M
Michael Keller
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,
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.
I am fairly new to Ruby, so please forgive fundamental misunderstandings!
Thanks a lot,
Michael
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,
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.
I am fairly new to Ruby, so please forgive fundamental misunderstandings!
Thanks a lot,
Michael