#47161 [Opn]: Dereferencing for array/function access
| From: | a at b dot c dot de | Date: | Tue, 20 Jan 2009 09:17:18 +0000 |
| Subject: | #47161 [Opn]: Dereferencing for array/function access | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-133046@lists.php.net to get a copy of this message | ||
ID: 47161
User updated by: a at b dot c dot de
Reported By: a at b dot c dot de
Status: Open
Bug Type: Feature/Change Request
Operating System: Windows (irrelevant)
PHP Version: 5.3.0alpha3
New Comment:
Perhaps I should just add....
although I reference Bug #23022, I'm not asking for this to be over
_arbitrary_ expressions, only arrays and callables. I don't want this
language turning into Perl :)
Previous Comments:
------------------------------------------------------------------------
[2009-01-20 09:08:50] a at b dot c dot de
Description:
------------
See Bug #23022.
Since we can have arrays that contain arrays, arrays that contain
functions, functions that return arrays and functions return functions;
and since both arrays and functions effectively define mappings between
their arguments/indices and their values;
and since we can already dereference array accesses into higher
dimensions (i.e., we can write $foo[1][2]);
I would like to be able to do the same thing with the other three
cases. The bug cited above asks for $foo(1)[2]; I'd like to add a
request for $foo[1](2) and $foo(1)(2).
Please, sir: can we have these?
Reproduce code:
---------------
<?php
$func = function($a) {
return function($b)use($a) {
return $a+$b;
};
};
echo $func(5)(3);
?>
Expected result:
----------------
8
Actual result:
--------------
Parse error: syntax error, unexpected '(', expecting ',' or ';' in
C:\test.php on line 9
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47161&edit=1