List Info

Thread: PEAR_Callback proposal




PEAR_Callback proposal
user name
2007-01-05 21:54:50
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://e
n.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

-- 
PEAR Development Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )