Bug #11596 Updated: More ways of passing by refrence
| From: | hewei at mail dot ied dot ac dot cn | Date: | Thu, 21 Jun 2001 01:40:13 +0000 |
| Subject: | Bug #11596 Updated: More ways of passing by refrence | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-57494@lists.php.net to get a copy of this message | ||
ID: 11596
User Update by: hewei@mail.ied.ac.cn
Status: Open
Bug Type: Feature/Change Request
Operating system: any
PHP Version: 4.0.5
Description: More ways of passing by refrence
As of 4.04, two new ways of reference passing are added:
func(new class()) and func(func2()) while func2 is defined as &func2(){...}. They are
VERY good for OOP.
But if the following two syntaxes are also supported, it will be really good.
1. func(&new class());
2. $obj =& func_get_arg($i);
The first one will make this possible:
$row =& $table->add(&new TableRow("valign=top"));
$cell =& $row->add(&new TableData("width=50%"));
while add is defined as &add($obj) {...;return $obj;}
And the second will make this possible:
$cell -> add(&$text1, &$text2, &$text3, ...);
while add function is going to use variable number of arguments.
But I didn't count on the following syntax being supported too:
foreach ($arr as &$value) {...} ( since there is a walk-arround: $value =&
$arr[$i] )
$cell =& $table->add(&new TableRow())->add(&new TableData())
{ since I may have requested to much :))
Previous Comments:
---------------------------------------------------------------------------
[2001-06-20 21:40:01] hewei@mail.ied.ac.cn
As of 4.04, two new ways of reference passing are added:
func(new class()) and func(func2()) while func2 is defined as &func2(){...}. They are
VERY good for OOP.
But if the following two syntaxes are also supported, it will be really good.
1. func(&new class());
2. $obj =& func_get_arg($i);
The first one will make this possible:
$row =& $table->add(&new TableRow("valign=top"));
$cell =& $row->add(&new TableData("width=50%"));
while add is defined as &add($obj) {...;return $obj;}
And the second will make this possible:
$cell -> add(&$text1, &$text2, &$text3, ...);
while add function is going to use variable number of arguments.
But I didn't count on the following syntax being supported too:
foreach ($arr as &$value) {...} ( since there is a walk-arround: $value =&
$arr[$i] )
$cell =& $table->add(&new TableRow())->add(&new TableData())
{ since I may have requested to much :))
---------------------------------------------------------------------------
[2001-06-20 21:36:19] hewei@mail.ied.ac.cn
As of 4.04, two new ways of reference passing is added:
func(new class()) and func(func2()) while func2 is defined as &func2(){...}. They are VERY good
for OOP.
But if the following two syntaxes are also supported, it will be really good.
1. func(&new class());
2. $obj =& func_get_arg($i);
The first one will make this possible:
$row =& $table->add(&new TableRow("valign=top"));
$cell =& $row->add(&new TableData("width=50%"));
while add is defined as &add($obj) {...;return $obj;}
And the second will make this possible:
$cell -> add(&$text1, &$text2, &$text3, ...);
while add function is going to use variable number of arguments.
But I didn't count on the following syntax being supported too:
foreach ($arr as &$value) {...} ( since there is a walk-arround: $value =& $arr[$i] )
$cell =& $table->add(&new TableRow())->add(&new TableData())
{ since I may request to much :))
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=11596