Re: PEAR_Callback proposal

From: Date: Fri, 05 Jan 2007 21:54:50 +0000
Subject: Re: PEAR_Callback proposal
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-45443@lists.php.net to get a copy of this message
Lukas Feiler wrote:
Hi, Alexey Borzov wrote:
Hi, Lukas Feiler wrote:
    
A couple of days ago I proposed the package PEAR_Callback;
see http://pear.php.net/pepr/pepr-proposal-show.php?id=468 It addresses three major limitations of the callback pseudo-type: - By looking at a callback pseudo-type variable you cannot tell if it really is a callback. - The callback pseudo-type does not allow you to specify arguments at the time you create the callback. - There is no way to force a user to pass only callback functions to your API, that meet certain requirements (i.e. accept certain arguments and have a certain return type)
      
All of these major limitations can be overcome by using the Command design pattern: http://en.wikipedia.org/wiki/Command_pattern I don't honestly see the benefit for PEAR in adding a wrapper around functions when all these checks are already available for classes / objects in PHP5.
    
PEAR_Callback effectively is a general command pattern implementation - it eliminates the need to write a command class for every callback function a programmer wants to use. But I do get your point. After all, OO languages like Java don't even have something like call_user_func(). Cheers, Lukas I'm still a fan of the code. I think callbacks are underused in PHP, just because the java approach is what you find in books doesn't mean its the best approach for php. -josh

« previous php.pear.dev (#45443) next »