Hello Andi,

Tuesday, October 5, 2004, 3:06:57 AM, you wrote:

> Marcus,

>  From reading this it doesn't seem as if this patch is array() specific but
> is a general one.

Yes it is a general one applicable to any function handling zvals with
greater data than the zval itself (array, string, maybe objects in ze1
compat mode).

> If I understand correctly, it will pass the hash (zval *) as-is and will 
> never do a zval_copy_ctor(). This means that this value must for all 
> practical purposes be read-only. What does this mean to the extension writer?
> Am I correct? We need to be sure that we don't add this new functionality 
> without being sure how the extensions should handle it in order not to get
> side effects.

The extension writer must only use this arg-info flag if he is sure the
variables are not touched inside the function. It behaves exactly like
force by reference as long as you pass variables. Though the latter is
most often used to modify parameters by design. So the extension writer
should take care whether to use it.

regards
marcus

> At 12:20 PM 10/2/2004 +0200, Marcus Boerger wrote:
>>Hello internals,
>>
>>Hello Andi,
>>
>>   here's another major speed improvement for array functions which
>>is probably also valid for other functions, too. The point is that
>>we have several functions not forcing parameters by reference because
>>they not only accept variables but also parameters by value and we
>>cannot pass values by ref directly. The solution is to automatically
>>find out whether to pass by ref or not. See the test script for
>>the difference - it's amazing in this example!
>>
>>http://php.net/~helly/php/ext/ze2/ze2-auto-ref-20040930.diff.txt
>>http://php.net/~helly/php/ext/ze2/ze2-auto-ref.php
>>
>>How does it work exactly:
>>
>>For example the function in_array() is defined with both arg types == 0
>>which mean not by ref. As a consequence when you have an array which is
>>stored somewhere else as a reference it will be copied. So the obvious
>>question is why not declare the function arg type as force by reference?
>>Simply because that does not work. The array functions are all designed
>>to accept arrays on the fly like in_array(2,array(1,2)). And unfortunatley
>>those direct values cannot be send by reference. But the compiler knows
>>whether it can send by ref or not and that is what the patch does. It
>>adds a new argument infor which tells the compiler to find out whether
>>the parameter can be passed by reference or must be passed by value.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to