Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:12228 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97930 invoked by uid 1010); 18 Aug 2004 22:02:05 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 91653 invoked from network); 18 Aug 2004 22:01:26 -0000 Received: from unknown (HELO iconoclast.caedmon.net) (66.45.232.17) by pb1.pair.com with SMTP; 18 Aug 2004 22:01:26 -0000 Received: from sarcasm ([10.20.31.100] helo=caedmon.net) by iconoclast.caedmon.net with esmtp (Exim 3.35 #1 (Debian)) id 1BxYUi-0002Cm-00 for ; Wed, 18 Aug 2004 18:01:20 -0400 Message-ID: <4123D1B5.3080203@caedmon.net> Date: Wed, 18 Aug 2004 18:01:25 -0400 User-Agent: Mozilla Thunderbird 0.5 (X11/20040306) X-Accept-Language: en-us, en MIME-Version: 1.0 To: internals@lists.php.net X-Enigmail-Version: 0.83.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Class Destruction / Reloading From: sean@caedmon.net (Sean Coates) -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello Internals, Has anyone given thought to a feature that allows (PHP) developer to invalidate classes (allowing the developer to re-load the class, with modified code)? I realize that this is not possible now, and for good reason. But I think the idea has potential. I asked Sara about this, yesterday, after the idea occurred to me, and she graciously whipped up a small extension that does exactly what I'm looking for, but she told me she thought it was a bad idea to be doing this (and also allows destruction of functions). I agree: without the proper safety nets, this is a dangerous thing to be doing. So, why do I want this functionality, in the first place? Consider a long-running application (not a web page, but, for instance, a sockets-based application). It would be very useful for me, as a developer, to be able to re-load parts of the application, without tossing the whole current instance of PHP (and all associated resources) - -- ie, doesn't release socket connections, but allows re-loading of the associated handlers. This could be accomplished by invalidating a class (destroying it, and marking all instanciated objects with a special type (__PHP_Destroyed_Class comes to mind, after __PHP_Incomplete_Class), and re-declaring the class. - -- sample code (working) -- - -- output -- Foo Bar I also spoke (typed) with Stig, who told me that this sounds more like a PHP 6 feature. I understand that class destruction breaks a lot of assumptions. As Sara pointed out, it will definitely break optimizers. Also, the potential for segfault is very high: Class Foo { function name() { echo "Foo\n"; } }; $Foo = new Foo(); shiva_destroy_class('Foo'); eval('Class Foo { function name() { echo "Bar\n"; } };'); $Foo->name(); results in segfault.. I'm, admittedly, completely out of my league here.. I played with the API a little, and was reminded of this. (-: It may seem like a stupid idea at first, but I think there's some value in re-loading pieces of code, and with the proper object counting/invalidation, sounds like it could be safe, but like I said, I don't know what I'm doing. Is this worth further discussion? S -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFBI9G1WppknrQMxQIRAjPOAJ9gsQ6AZlwd5QI6+CYerGOgtsKwhQCfejxZ zfMP6MgKuGvHx7dO4mPNh90= =GR/W -----END PGP SIGNATURE-----