Re: Object method as handler functions in PHP4/Zend

From: Date: Wed, 30 Jun 1999 19:25:02 +0000
Subject: Re: Object method as handler functions in PHP4/Zend
References: 1 2 3 4 5 6 7 8  Groups: php.dev 
Request: Send a blank email to php-dev+get-7893@lists.php.net to get a copy of this message
More general would be to allow an optional data parameter to the various functions that call user-defined functions, so you could do something like: function do_array_walk($a, $data) { $data->munge($a); } or function do_array_walk($a, $data) { $data++; do_stuff($a); } etc. There's no good reason to tie that optional parameter to objects that I can see. Jim Chuck Hagenbuch wrote: > > Quoting Zeev Suraski <zeev@zend.com>: > > > If you know you're expecting an object context, make your function accept > > $obj and $method, and inside the function, call $method() if $obj is empty, > > or $obj->$method() if it isn't. > > Would it be possible to add an optional argument specifying an object > reference to all of the functions that take a function name as a parameter > (array_walk, usort, etc). > > This would allow you to write: > > mysort($a, $b, $obj) {} > > and call: > > $foo = usort($bar, 'mysort', $foo_object); > > This at least lets you avoid setting global variables for mysort() to access > before calling usort. > > -chuck > > -- > Charles Hagenbuch, <chagenbu@wso.williams.edu> > -- > must... find... acorns... *thud* > > -- > PHP Development Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > For additional commands, e-mail: php-dev-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.dev (#7893) next »