From: "Mauricio Fernández" Date: 2004-06-26T02:19:40+09:00 Subject: Re: Is it considered Harmful? On Sat, Jun 26, 2004 at 01:35:21AM +0900, Jim Weirich wrote: > > gabriele renzi said: > > il Fri, 25 Jun 2004 16:51:05 +0200, Michael Walter > > ha scritto:: > > > >>Another reason would be that it might be useful to change the object _in > >>place_. That is, all existing references suddenly point to the new > >> object. > > > > in evil.rb (you can find it at rubyforge) you even have Object#become > > if you need it ;) > > Are there limitations on evil.rb's implementation of become? How do you > get around Guy's concerns about crashing? evil.rb's Object#become is restricted in several ways, to try to prevent crashes. Some of the checks include: * in general, refuse operations that would break implicit assumptions in Ruby (memory layout & internal structs): * refuse to swap "core classes" * refuse to swap modules with non-modules (cause they might be in a klass chain) * refuse to swap objects whose classes use incompatible "internal types" * refuse to operate on immediate values (Fixnum, symbols, true, false, nil...) * prevent cycles in the klass chains * check EXIVARs ... Additionally, the method cache is invalidated after two objects are swapped. -- Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com i dont even know if it makes sense at all :) This is an experimental patch for an experimental kernel :)) -- Ingo Molnar on linux-kernel