RE: [PHP-DEV] Feature request
| From: | Andi Gutmans | Date: | Fri, 10 Nov 2006 03:13:45 +0000 |
| Subject: | RE: [PHP-DEV] Feature request | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-26447@lists.php.net to get a copy of this message | ||
There are some cases where this could start becoming quite challenging and
we might get into reference counting/separation problems, i.e.:
function foo()
{
return array(1,2,3);
}
foo()[1] = 4;
or
function foo()
{
$arr = array();
$arr[1] =& $var;
}
foo()[1] = 2;
Anyway, these are the kind of things what we'd need to consider and with a
few more minutes I can start thinking of some rougher ones where we'd need
to return by reference and gracefully handle when you don't return by
reference...
I'm not opposed to this kind of syntax but it needs quite a lot of thorough
thinking and it's a great example of where test-driven development would
really be suitable (have like 20 of these weird cases in tests and try and
understand if we can get this 100% right).
Andi
> -----Original Message-----
> From: Stanislav Malyshev [mailto:stas@zend.com]
> Sent: Thursday, November 09, 2006 5:44 PM
> To: internals@lists.php.net
> Subject: Re: [PHP-DEV] Feature request
>
> >>> <?php
> >>> function foo()
> >>> {
> >>> return array(1,2,3,4,5,6);
> >>> }
> >>>
> >>> echo foo()[4]; // <---- it that
>
> It looks a bit perl-ish indeed but I don't see much trouble
> in having that it people really need it...
>
> --
> Stanislav Malyshev, Zend Products Engineer stas@zend.com
> http://www.zend.com/
>
> --
> PHP Internals - PHP Runtime Development Mailing List To
> unsubscribe, visit: http://www.php.net/unsub.php
>