syntax idea: simplifed ifs
Ameer Armaly
ameer_armaly at hotmail.com
Mon Apr 10 17:13:41 PDT 2006
"Derek Parnell" <derek at psych.ward> wrote in message
news:noyfbcyf3t01$.m2gl86mb13se.dlg at 40tude.net...
> 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;
> }
>
That's true. In such a case I think that the above proposal might work, or
perhaps the templates that Hasan suggested.
> --
> 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