Jump to page: 1 24  
Page
Thread overview
syntax idea: simplifed ifs
Apr 10, 2006
dennis luehring
Apr 10, 2006
Derek Parnell
Apr 10, 2006
dennis luehring
Apr 11, 2006
Derek Parnell
Apr 10, 2006
Ameer Armaly
Apr 11, 2006
Derek Parnell
Apr 11, 2006
Ameer Armaly
Apr 11, 2006
Hasan Aljudy
Apr 11, 2006
Derek Parnell
Apr 13, 2006
Bruno Medeiros
Apr 13, 2006
BCS
Apr 14, 2006
Derek Parnell
Apr 14, 2006
Bruno Medeiros
Apr 14, 2006
Hasan Aljudy
Apr 14, 2006
Dan
Apr 15, 2006
Alexander Panek
Apr 21, 2006
Dan
Apr 11, 2006
dennis luehring
Apr 18, 2006
Fredrik Olsson
Apr 18, 2006
dennis luehring
Apr 19, 2006
Fredrik Olsson
Apr 19, 2006
dennis luehring
Apr 19, 2006
BCS
Apr 11, 2006
Chris Miller
Apr 11, 2006
Derek Parnell
Apr 11, 2006
BCS
Apr 11, 2006
pragma
Apr 11, 2006
Charles
Apr 11, 2006
Deewiant
Apr 12, 2006
James Dunne
Apr 12, 2006
David Medlock
Apr 13, 2006
Bruno Medeiros
Apr 13, 2006
Frank Benoit
April 10, 2006
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
April 10, 2006
On Tue, 11 Apr 2006 08:04:21 +1000, dennis luehring <dl.soluz@gmx.net> wrote:

> 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)

A good one too, in my opinion. The || symbol would also be useful.

  if ( [a || b || c] >= h )

-- 
Derek Parnell
Melbourne, Australia
April 10, 2006
Derek Parnell wrote:
> On Tue, 11 Apr 2006 08:04:21 +1000, dennis luehring <dl.soluz@gmx.net>  wrote:
> 
>> 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)
> 
> 
> A good one too, in my opinion. The || symbol would also be useful.
> 
>   if ( [a || b || c] >= h )

or think of

if( [a || b || c ] >= [ h && b ] )

April 10, 2006
"dennis luehring" <dl.soluz@gmx.net> wrote in message news:e1ekp6$jr7$1@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.


April 11, 2006
On Tue, 11 Apr 2006 00:24:14 +0200, dennis luehring wrote:

> Derek Parnell wrote:
>> On Tue, 11 Apr 2006 08:04:21 +1000, dennis luehring <dl.soluz@gmx.net> wrote:
>> 
>>> 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)
>> 
>> A good one too, in my opinion. The || symbol would also be useful.
>> 
>>   if ( [a || b || c] >= h )
> 
> or think of
> 
> if( [a || b || c ] >= [ h && b ] )

Not sure what that would mean ... is it ...

  if ( (a >= h || b >= h || c => h) && ((a >= b || b >= b || c => b)))

OR

  if ( (a >= h && a >= b) || (b => h && b >= b) || (c => h && c >= b) )

I think the idea should be kept at one '[...]' group only and one of '&&','||' per group ( that is ... don't mix && and || inside the [] ).

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocracy!"
11/04/2006 9:57:47 AM
April 11, 2006
On Mon, 10 Apr 2006 19:18:55 -0400, Ameer Armaly wrote:

> "dennis luehring" <dl.soluz@gmx.net> wrote in message news:e1ekp6$jr7$1@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
April 11, 2006
dennis luehring wrote:
> 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

I've always wanted something like this!!!! but I think the proposed syntax might not fit very well with the D grammar.

hmm, come to think of it, maybe it can already be implemented with templates.

so,

if( x == 10 || x == 20 || x == 30 )

becomes:
if( equals!(x).anyOf( 10, 20, 30 ) )

or something like that!

any template guru up to it?

On a side note: the expression( x == 10 && x == 20 && x == 30 ) is rediclious, it's always false ;)
April 11, 2006
On Mon, 10 Apr 2006 18:03:57 -0600, Hasan Aljudy wrote:

> dennis luehring wrote:
>> 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
> 
> I've always wanted something like this!!!! but I think the proposed syntax might not fit very well with the D grammar.
> 
> hmm, come to think of it, maybe it can already be implemented with templates.
> 
> so,
> 
> if( x == 10 || x == 20 || x == 30 )
> 
> becomes:
> if( equals!(x).anyOf( 10, 20, 30 ) )
> 
> or something like that!
> 
> any template guru up to it?
> 
> On a side note: the expression( x == 10 && x == 20 && x == 30 ) is rediclious, it's always false ;)

Try not using literals ... ;-)

The expression( x == a && x == b && x == c ) is not always false.

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocracy!"
11/04/2006 10:15:53 AM
April 11, 2006
"Derek Parnell" <derek@psych.ward> wrote in message news:noyfbcyf3t01$.m2gl86mb13se.dlg@40tude.net...
> On Mon, 10 Apr 2006 19:18:55 -0400, Ameer Armaly wrote:
>
>> "dennis luehring" <dl.soluz@gmx.net> wrote in message news:e1ekp6$jr7$1@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


April 11, 2006
> I've always wanted something like this!!!! but I think the proposed syntax might not fit very well with the D grammar.

another idea

> hmm, come to think of it, maybe it can already be implemented with templates.

oh no! what we need is more syntactic sugar - not another boost library (hell) :-)

> so,
> 
> if( x == 10 || x == 20 || x == 30 )
> 
> becomes:
> if( equals!(x).anyOf( 10, 20, 30 ) )
> 
> or something like that!
> 
> any template guru up to it?
> 
> On a side note: the expression( x == 10 && x == 20 && x == 30 ) is rediclious, it's always false ;)

example version 2:

if( x == a && x == b && x == c )

=>

if( x == [a && b && c] )

--> or maybe even "if( x == [a,b,c](&&))"
but this goes a little bit to fast into the "how can we integrate vector stuff" direction...

ciao dennis
« First   ‹ Prev
1 2 3 4