RE: [PHP-DEV] Inline constructing/cloning and inline foreach listing
| From: | John Crenshaw | Date: | Tue, 07 Jun 2011 13:53:18 +0000 |
| Subject: | RE: [PHP-DEV] Inline constructing/cloning and inline foreach listing | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-53141@lists.php.net to get a copy of this message | ||
> // Inline constructing:
> $car = (new CarFactory())->makeCar();
> // Inline cloning:
> $tomorrow = (clone $today)->add($one_day);
Agreed. The fact that these expressions can't be wrapped in parentheses never made any sense to
me.
> foreach ($arrays as list($e1, $e2, $e3)) { ...
Disagree. This feels very obtuse. I wouldn't expect this construct to work at all, and even if
it did, it is highly ambiguous (I.E. at first I thought you were intending to grab 3 entries at a
time, rather than extracting entries from a second array).
John Crenshaw
Priacta, Inc.