Re: Re[2]: [PEAR-DEV] [PEPr] Proposal for PEAR::PEAR_Delegator
| From: | lingwitt at bellsouth dot net | Date: | Sat, 05 Mar 2005 07:42:36 +0000 |
| Subject: | Re: Re[2]: [PEAR-DEV] [PEPr] Proposal for PEAR::PEAR_Delegator | ||
| References: | 1 2 3 4 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-36547@lists.php.net to get a copy of this message | ||
Problem fixed.
All delegates that do not follow the protocol are false delegates.
When adding new delegates, specify true and false delegates with a boolean:
$delegator->addDelegate(d1, d2, d3, false, d4, d5, d6, true, d7, d8, d9)
True delegates:
d1, d2, d3 //By default
d7, d8, d9
False delegates:
d4, d5, d6
The new code is posted.
Try:
$this->addDelegate(false, new Dataspace());
On 4 Mar 2005, at 15:21, lingwitt@bellsouth.net wrote:
Very interesting. But, there are issues. You want to add old classes as delegates. The problem is that their methods do not follow the protocol. The solution: append the delegator. Two issues: *Aesthetically, this is not good, as users who want to have access to the delegator will need to sift through the argument list. This isn't really too bad since users need to add an extra parameter anyway. *More importantly, consider what will happen with methods that take a variable number of arguments: they will not know the last one is not meant for processing. Perhaps more methods need to be available to describe certain delegates or methods as those that do not take the extra argument. Is this agreeable? Thanks for your response. On 4 Mar 2005, at 11:16, Sven Fuchs wrote:--PEAR Development Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpShall I assume everyone is satisfied with the proposal as it stands? Checkout http://pear.php.net/pepr/pepr-proposal-show.php?id=210Just done this ... Great! :) Hmm, you've already started voting, so I hope I'm not too late with the following: * Thus, delegated methods must be defined as follows: * <code> * accesslevel function functionName($owner, ...); * </code> * Note, however, that the user of the method need only consider those * parameters that follow the first parameter. So, it's impossible to delegate to already existing classes without modifying them, since __call() prepends the Delegator to the arguments of the called method? I tried to delegate the Dataspace class from Wact, http://wact.sourceforge.net/xref/framework/util/dataspace.inc.php.source.html class MyTestDelegator extends PEAR_Delegator { function __construct() {$this->addDelegate(new Dataspace());} } $test = new MyTestDelegator(); $test->set('foo', 'bar'); ... won't work, since Dataspace::set($name, $value) gets called with the arguments set($delegator, $name, $value). (Or possibly I've just missed the intended way to get around this?) That would mean, that we could only delegate to classes, that are explicitly ment to be used as delegates. A simple way around that could be to append (not prepend) the Delegator to the arguments: in PEAR_Delegator::__call() $args = array_merge($args, array($delegate)); instead of $args = array_merge(array($delegate), $args); I'd really apreciate to be able to delegate existing classes without having to modify them ...