Ternary operator enhancement for fluent code
| From: | waldschrott | Date: | Wed, 28 Jun 2000 14:11:57 +0000 |
| Subject: | Ternary operator enhancement for fluent code | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-22627@lists.php.net to get a copy of this message | ||
@Core-devs:
I´ve a little proposal, what about improving the ternary operator a bit.
I like the ternary operator and I´ve used it very often, but there´s also a configuration I´ve used very often.
This one:
if (!$class=$val1) $class=$val2;
what is ternary:
$class = $val1 ? $val1 : $val2;
what about if this would be possible:
$class = $val1 ? $val2;
using methods and so on the current syntax can become very long:
$this->foo= $this->dfoo->foobie ? $this->dfoo->foobie : $this->dfoo->foobie2);
what would be *a lot smaller* if so:
$this->foo= $this->dfoo->foobie ? $this->dfoo->foobie2);
this enhancement would be also *downwards compatible*, because the missing of : throws an error message, in my opinion it could also increase the *performance* if the middle term must not be evalulated twice fot the reason that it does not exist
regards
ps. in fact it´s no visible ternary operator anymore, it´s like a virtual ternary operator, consisting of two parts, you could name it twice operator if you like :)
--
o----------0-¬---------O-·---¬----o---®-----o o O ° .
| http://www.kiffen.de | pRoteçt y0ur bRaín |0 O ° ¤ °
·
0°·³°²'²³-¹'³´³°^°³~³²³°'³²²¨³²^³¹³²°²³`³º³°Þ °
o © ° . ·
| psychedelic experience | gott@kiffen.de | O ° o °
o-¬--o--0-----©-·--O-----o-----0-¤----------o 0 ° · ° . ¤ ·