ID:1903758
 
Redundant
Applies to:DM Language
Status: Redundant

This feature has already been implemented, or is already achievable with existing methods.
We currently have:
if(a || b)


But to my knowledge we don't have:
if(a ^^ b)


I believe it would be a functional && helpful addition to the list of operators.
One current workaround:

if((a || b) && !(a && b))
More workarounds, just for fun:
 !a == !!b
!a != !b
!!a == !b
!!a != !!b
!!a ==!!!b
// etc... any odd number of !s works, I guess, but both sides need at least one to convert a and b to 0 or 1
I've played enough roguelikes to know that shop has a lot of rings and potions and seems to have been invaded by a parade of ants and blobs.
In response to Ter13
O. o wut
In response to Ter13
Ter13 wrote:
I've played enough roguelikes to know that shop has a lot of rings and potions and seems to have been invaded by a parade of ants and blobs.

I get it lel
Lummox JR resolved issue (Redundant)
As useful as this would be, I've never heard of a language supporting this. The easiest workaround I know of is !a != !b.
In response to Lummox JR
Lummox JR wrote:
As useful as this would be, I've never heard of a language supporting this. The easiest workaround I know of is !a != !b.

Personally, I think the reason no other language does this is because it doesn't short circuit like && and || do, because that's how the logical operators work; It'd be nice to have it, but for consistancy I wouldn't because of short circuiting. I use something like
bool x = a;
bool y = b;
if(x ^ y)

in C++ though.
In response to Pokemonred200
Agreed. I think that's the reason as well.
In response to Lummox JR
To quote Dennis MacAlistair Ritchie (Creator of C):

"There are both historical and practical reasons why there is no ^^ operator."

"The practical is: there's not much use for the operator"

"The main point of && and || is to take advantage of their short-circuit evaluation not only for efficiency reasons, but more often for expressiveness and correctness."

"By contrast, an ^^ operator would always force evaluation of both arms of the expression, so there's no efficiency gain. Furthermore, situations in which ^^ is really called for are pretty rare, though examples can be created. These situations get rarer and stranger as you stack up the operator"

In conclusion:
"My guess is that &,&& |,||; ^,^^ is a false symmetry. But it's one that people seem to want, and, though it's not much help, adding it wouldn't do much harm."