April 19, 2006
Fredrik Olsson schrieb:
>> how would you write these example in your in syntax?
>>
> Not that easy as sets is mostly not a simple solution for complex conditions, but a simple solution to complex set problems.
> 
>> if( x == [ a && !b || c ] ) --> if( x == a && x == !b || x == c )
>>
>> if( x == [ a && (!b || c)] ) --> if( x == a && ( x == !b || x == c ) )

> These are not good examples of where sets strength lies, this is a better example:

set strength lies in "or" operations

> if (x == [a || b || c]) --> if (x == a || x == b || x == c)
> would be
> if (x in <a, b, c>)

thats clear - but you can't write my above examples simpler with your "in"

> But the true power lies in what can be done with sets, unions, intersections, etc.

examples - "in" isn't enough (its just the "or" part of my idea)
April 19, 2006
dennis luehring wrote:
> 
> how would you write these example in your in syntax?
> 
> if( x == [ a && !b || c ] ) --> if( x == a && x == !b || x == c )
> 
> if( x == [ a && (!b || c)] ) --> if( x == a && ( x == !b || x == c ) )
> 
> ciao dennis
> 
I wouldn't use any shorthand, I would use the expanded form

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

to much shorthand just leads to confusion
April 21, 2006
>> a && a.doSomething();
>> or
>> a = a || defaultValue;
>> 
>> It feels so much better than:
>> 
>> if(a) a.doSomething();
>> if(!a) a = defaultValue;
>
>	b |= a;
>	writefln(b);
>	a |= b;
>	writefln(a);
>Works quite fine for me.

Dear Alexander,  I'm not sure if you've read the manual on what different operators do exactly.  || is a logical or, that is, it returns one OR the other. | is a bitwise or, that is, it returns a value in which if a given bit is set in the value on either side, it will be set in the return value.

|= is a bitwise or, so if you say:

x = 1;
x |= 2; // 3
x = 1 || 2; // 1
x = 0 || 2; // 2

You with me?


1 2 3 4
Next ›   Last »