-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Saturday 22 November 2003 22:46, T. Onoma wrote:
> Is it right to have substantiated objects modifiable on the fly by
> redefinitions of their class? Do you know of any program that actually
> utilizes this? Ruby is *really* dynamic, perhaps a little too so. This

Yes.  I've used it a few times, although in most cases Ruby's singletons are a 
better solution.  If you want to hook into libraries that use objects that 
you don't create, this is the only way to do that.  

If I provide you with a package Foo that parses some file and returns a tree 
of objects representing the data which is capable of dumping that object to a 
string (say, an XML parser :-) and you want to change the output format, the 
easiest way is to redefine to_s() on the object Class.  The harder, and more 
error prone, way is to traverse the entire tree of objects, implementing a 
singleton override of to_s().

I find this feature of Ruby quite useful for changing the behavior of code 
that I didn't write, or even code that I wrote but that -- in some situation 
- -- I want to have different behavior globally, across a large number of 
instances.

- -- 
### SER   
### Deutsch|Esperanto|Francaise|Linux|XML|Java|Ruby|Aikido|Dirigibles
### http://www.germane-software.com/~ser  jabber.com:ser  ICQ:83578737 
### GPG: http://www.germane-software.com/~ser/Security/ser_public.gpg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE/wNZFP0KxygnleI8RApIWAKDGoP8fnVpY70otytp9wSMxuOyldQCfSrrf
69D1fzkKF9rGoULQxIOIS58=
=YeUC
-----END PGP SIGNATURE-----