|
Posted by Oli Filth on 11/15/05 22:17
Jerry Stuckle said the following on 15/11/2005 20:02:
> Oli Filth wrote:
>
>> Jerry Stuckle said the following on 15/11/2005 17:09:
>>
>>>
>>> For instance, what is supposed to happen if you do something like:
>>>
>>> function f1 (&$i) {
>>> $i++;
>>> }
>>>
>>> Java and C++ handle this by not allowing a temporary to be passed as
>>> a reference (compiler error) - which is correct operation, IMHO.
>>
>>
>> However, even in Jerry's example, even without the benefit of const
>> enforcement, I don't see why PHP can't just assign to the temporary
>> variable - what harm would it do?
>
> But then let's take another case:
>
> f1(3);
>
> NOW what does f1 increment?
Good example!
In that case, I repeat my disappointment that PHP doesn't allow one the
option to indicate a constant reference!!
Alternatively, maybe PHP should throw an error if a literal is passed
(as in your 2nd example), but cope with temporary variables - although
there's probably a caveat I'm not seeing with that either...
--
Oli
Navigation:
[Reply to this message]
|