RE: [PEAR-DEV] PEAR_Callback proposal
| From: | Lukas Feiler | Date: | Fri, 05 Jan 2007 21:30:52 +0000 |
| Subject: | RE: [PEAR-DEV] PEAR_Callback proposal | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-45442@lists.php.net to get a copy of this message | ||
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