Req #66832 [Opn->Wfx]: Feature: Reverse assignment string operators
| From: | nikic@php.net | Date: | Thu, 06 Mar 2014 11:55:06 +0000 |
| Subject: | Req #66832 [Opn->Wfx]: Feature: Reverse assignment string operators | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-184558@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66832&edit=1
ID: 66832
Updated by: nikic@php.net
Reported by: nicolas dot giraud dot dev at gmail dot com
Summary: Feature: Reverse assignment string operators
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: Strings related
Operating System: All
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
This is too exotic. No language that I am aware of supports postfix compound assignment operators.
The use cases are rather limited and it has a lot of potential of confusing and typos, as it's
so close to the normal compound assignment syntax.
Furthermore we'd have to add this for all other operators as well, to stay consistent. In which
case we'd run into issues like =& already being the by-ref assignment operator.
Previous Comments:
------------------------------------------------------------------------
[2014-03-06 09:50:24] nicolas dot giraud dot dev at gmail dot com
Description:
------------
This is not a bug but a feature request. I thought someone already asked it but I wasn't able
to find anything like that.
I would like to know if it's possible to have reversed assignment string operator.
Thank you
Test script:
---------------
$a =. $b; // same as $a = $b . $a;
Expected result:
----------------
$a = 'World';
$b = 'Hello ';
$a =. $b; //$a worth now "Hello World";
//Multiple string operations in assignements
$a = 'a'; $b = 'b'; $c = 'c';
$c .= $b .= $a; //$c worth now 'cba'
$a = 'a'; $b = 'b'; $c = 'c';
$c =. $b =. $a; //$c worth now 'abc'
Actual result:
--------------
Not implemented (yet?)
Only the following snippet works:
$a = 'a'; $b = 'b'; $c = 'c';
$c .= $b .= $a; //$c worth now 'cba'
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66832&edit=1