On 9/12/09 7:06 AM, Dmitriy Sintsov wrote:
To me it's easy to release the new version, patch
is one letter. But,
I've studied other extensions and for example very professional Semantic
MediaWiki also declares third parameter of tag hook method by reference:
static public function doAskHook($querytext, $params,&$parser) {
Most of those are old leftovers from PHP 4, which would copy objects
instead of using sane value-reference semantics. These are being cleaned
up in dev work for 1.6 as people are more actively testing with PHP 5.3.0.
References for hook parameters should *only* be used for out-parameters
where the hook needs to be able to return a new value to the caller,
*not* for simply passing objects.
What should I do, wait for the Parser.php patch or to
use less efficient
passing of large Parser object by value?
Using a PHP reference here is actually less efficient and more error-prone.
Passing objects "by value" in PHP 5 works the same as it does in Java,
Python, etc -- that is, you're actually passing around a reference to
the object... but if you were to, say, assign a different object to the
variable in your function, *that* change would not propagate back to the
caller, as you're passing the reference by value.
Yeah I know, it's confusing. ;) Just stay away from references unless
you're realllllly sure you need em. ;)
-- brion