On Tue, Feb 26, 2013 at 7:10 PM, Nikita Popov <nikita....@gmail.com> wrote:

> On Tue, Feb 26, 2013 at 7:41 AM, Dmitry Stogov <dmi...@zend.com> wrote:
>
>> Hi Nikita,
>>
>> I like the idea.
>> But note, that it may cause some unexpected behaviour and bugs.
>> I didn't test the patch I just guess it on my previous experience
>> introducing similar features.
>>
>> - usage expression in write context (e.g. passing constant by reference)
>>
>> function foo(&$foo) {}
>> foo("abc"[0]);
>>
>> - destruction of temporary result
>>
>> ($a . $b)[4]; // if ($a.$b) is destroyed?
>>
>> - in some cases destruction of temporary result may cause destruction of
>> final result
>>
>> ((object)(array("a"=>"b")))->a = "c"; // temporary object may be
>> destroyed before assignment
>>
>> All these edge cases must be carefully analyzed.
>> I like the current patch, and in case the edge cases won't require many
>> hacks, I'm all for it.
>>
>> Thanks. Dmitry.
>>
>
> All these edge-cases are covered by not being allowed :) The old (new
> Foo)->bar syntax did not allow usage as a variable and I stayed with that.
> I.e. (expr)->xyz will still be an expression, not a variable and as such
> (expr)->xyz = 'foo' will be a syntax error.
>

At least the first case (passing constant by reference) is already in
PHP-5.5 and should be fixed.


> I stayed with the old behavior because I thought that it would just be a
> small bugfix-like change that way, whereas allowing usage in write-context
> could require larger changes (though I haven't tried, maybe its just as
> simple). But now that everybody seems to think that this is a major change
> that requires serious consideration, I guess I can have a look at the
> write-context use too :)
>

Yeah. It's not a simple patch. In the past, we had a lot of problems after
introducing foo()[$i] syntax, because some edge cases were not taken in
account.

Thanks. Dmitry.

Reply via email to