syntax idea: simplifed ifs

Derek Parnell derek at psych.ward
Mon Apr 10 17:03:27 PDT 2006


On Mon, 10 Apr 2006 19:18:55 -0400, Ameer Armaly wrote:

> "dennis luehring" <dl.soluz at gmx.net> wrote in message 
> news:e1ekp6$jr7$1 at digitaldaemon.com...
>> for example how often do we use constructs like
>>
>> if( x ==  10 && x == 20 && x == 30 )
>>
>> simplified:
>> if( x == [10 && 20 && 30] )
>>
>> if( a >= h && b >= h && c >= h )
>>
>> simplified:
>> if( [a && b && c] >= h )
>>
>> (just an idea)
>>
>> ciao dennis
> Considering that you can't have multiple assignments to a variable, if you 
> had that many possible OR conditions,, couldn't you just use a combined 
> switch like so:
> 
> switch(x)
> {
>   case 10:
>   case 20:
>   case 30:
>     ...
>   default:
>     break;
> }
> This still leaves open the issue of multiple variables though; what you 
> suggest may work.

The problem with 'switch' is it requires literals or consts. One can't do
...

  switch (h)
  {
     case a:
     case b:
     case c:
         ...
         break;
     default: break;
  }

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocracy!"
11/04/2006 10:01:40 AM



More information about the Digitalmars-d mailing list