Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:12489 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9073 invoked by uid 1010); 31 Aug 2004 03:42:20 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 9048 invoked from network); 31 Aug 2004 03:42:20 -0000 Received: from unknown (HELO newweb.akbkhome.com) (202.81.246.113) by pb1.pair.com with SMTP; 31 Aug 2004 03:42:20 -0000 Received: from develop ([192.168.0.40] ident=alan) by newweb.akbkhome.com with esmtp (Exim 4.33) id 1C1zdc-00054p-MA for internals@lists.php.net; Tue, 31 Aug 2004 11:48:52 +0800 Message-ID: <4133F497.7080002@akbkhome.com> Date: Tue, 31 Aug 2004 11:46:31 +0800 User-Agent: Mozilla Thunderbird 0.7.3 (X11/20040805) X-Accept-Language: en-us, en MIME-Version: 1.0 To: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: native events in PHP From: alan@akbkhome.com (Alan Knowles) I've been looking at events in PHP, at present, in PEAR, there are lots of different methods to add callbacks, to packages, for various purposes. It seriously lacks cohesion, and would be nice to sort out at the language level. Having seen C#, while not perfect, it is an interesting model. There's a very short note on C#, and an idea for a PHP syntax. http://www.akbkhome.com/wiki.php/DBDO/signals.html It suggests: class xxxx { // event registers a method, that hooks into the generic event handler. public event $onDebug = array(); function somemethod() { // add a handler to an event.. // this is the natrual syntax for this, but does open the door to someone wiping the stack! $this->onDebug[] = array($this,'mycallback'); // initiate the signals. (function name matches the var!) $this->onDebug($x,$y); } // a handler.. function mycallback($x,$y) { echo "debug hander got $x , $y\n"; } } Anyone care to comment on a) the feasibility b) the "should it be implemented" question. c) the "any better ideas" question... Regards Alan