Mit freundlichen Grüßen aus Paderborn
Christian Stoller
Softwareentwicklung
LEONEX Internet GmbH
Technologiepark 20
33100 Paderborn
Tel: 05251-14807-27
Fax: 05251-14807-30
HRB 8694 AG Paderborn
Geschäftsführer: Stephan Winter
------------------------------------------------------------------
APPsolut nützlich - mit Apps neue Geschäftsmodelle & Geschäftsprozesse gestalten
Dienstag, 04. November 2014, mehr unter http://bit.ly/YXDNa3
------------------------------------------------------------------
-----Original Message-----
From: Rowan Collins [mailto:rowan.coll...@gmail.com], Sent: Thursday, September
25, 2014 11:10 AM
> Rowan Collins wrote (on 24/09/2014):
>> On 24/09/2014 22:33, Andrea Faulds wrote:
>>> On 24 Sep 2014, at 22:17, Rowan Collins <rowan.coll...@gmail.com> wrote:
>>>
>>>> Perhaps rather than a magic function or constant, though, the switch
>>>> statement could be extended with an "as" argument, which would store
>>>> the evaluated expression into a normal variable, allowing nesting,
>>>> and easier optimisation of the engine where the feature isn't used.
>>>> Thus you could write this:
>>>>
>>>> switch( some_expression() as $switch_value ){
>>>> case 1:
>>>> do_something();
>>>> break;
>>>> //...
>>>> default:
>>>> throw new Exception('Undefined input: ' . $switch_value);
>>>> break;
>>>> }
>>> Incredibly, some brave soul has gone back in time and already
>>> implemented this, when none of us was looking!
>>>
>>> switch($switch_value = some_expression()) {
>>> ...
>>> }
>>>
>>
>> Heh, now I feel like a fool for not thinking of that.
>>
>> Treating assigments as expressions just isn't something that jumps to
>> mind, I guess!
>>
>
> Anyone have any thoughts on the use(operator) part, though?
>
> Am I missing something equally obvious there? Or just, it doesn't
> interest people much as an idea?
Why should one add a new operator in that context if it is already
possible with assigments as expressions?
This makes the language more complex without getting any improvement.