From: Daniel Schierbeck Date: 2005-11-26T01:07:26+09:00 Subject: Re: `finalize' method? Hugh Sasse wrote: > On Sat, 26 Nov 2005, Daniel Schierbeck wrote: > >> I just think it's weird that PHP has destructors and Ruby doesn't ;) >> >> http://www.php.net/manual/en/language.oop5.decon.php > > I find this tricky too: the only model I can think of is that where > you need destructors, your constructor desstructs, and you get at > the object with a block, in the style of open("file"){|f| ...}; if > you see what I mean. No, not really. I really can't stretch enough that I'm a noob... :) >> I'm not really into C, neither am I familiar with the Ruby implementation, but >> doesn't all variables just reference an object? So somewhere, an object is >> stored, and each variable referencing it really only holds that object's id. I >> imagine the `finalize' method could be run, and afterwards, the object could >> be replaced with nil, maybe retaining the old object id. That way any >> variables that point to the object will be nil. > > But there is only one nil in the system, so it can't have many ids. Could the object then by replaced by a reference to the nil object? Again, I'm talking theoretically... Cheers, Daniel