Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
September 13, 2003 logical xor | ||||
---|---|---|---|---|
| ||||
Im wondering why there is no logical xor operator ( ^^ ) ? Using ^ works but its somewhat unbalanced. -- Nicolas Repiquet |
September 13, 2003 Re: logical xor | ||||
---|---|---|---|---|
| ||||
Posted in reply to DeadCow | DeadCow wrote:
> Im wondering why there is no logical xor operator ( ^^ ) ?
>
> Using ^ works but its somewhat unbalanced.
>
> -- Nicolas Repiquet
Use != :)
-- andy
|
September 13, 2003 Re: logical xor | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andy Friesen | "Andy Friesen" <andy@ikagames.com> a écrit dans le message news: bjuaqj$2p63$1@digitaldaemon.com... > Use != :) > > -- andy True =) Now its not unbalanced, its ugly ! -- Nicolas Repiquet |
September 13, 2003 Re: logical xor | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andy Friesen | > DeadCow wrote:
> > Im wondering why there is no logical xor operator ( ^^ ) ?
> >
> > Using ^ works but its somewhat unbalanced.
> >
> > -- Nicolas Repiquet
>
> Use != :)
>
This is not the same when arguments are not already bool and if it is already bool, ^ would give the proper result... so why not add it?
|
September 13, 2003 Re: logical xor | ||||
---|---|---|---|---|
| ||||
Posted in reply to DeadCow | DeadCow wrote:
> Im wondering why there is no logical xor operator ( ^^ ) ?
>
> Using ^ works but its somewhat unbalanced.
>
> -- Nicolas Repiquet
>
there is no need for another boolean xor, you have to eval both sizes
and you have ^ or != already
(the only reason for && and || is they only eval one side if they can)
|
September 13, 2003 Re: logical xor | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Wynn | In article <bjv578$10m2$1@digitaldaemon.com>, Mike Wynn wrote: > DeadCow wrote: >> Im wondering why there is no logical xor operator ( ^^ ) ? >> >> Using ^ works but its somewhat unbalanced. >> >> -- Nicolas Repiquet >> > > there is no need for another boolean xor, you have to eval both sizes > and you have ^ or != already > (the only reason for && and || is they only eval one side if they can) There's one reason I can think of: - There wouldn't be the periodical question "Why is there no ^^?" on the newsgroup -> less time wasted explaining why it's not actually needed ;) Another reason: consistency. (Although we're talking about C's descendant here -- I won't hold my breath. IMO it would be best to just get rid of most operators and replace them with member functions!) Yet I wouldn't be too unhappy if logical xor was implemented -- just for the heck of it. -Antti |
September 16, 2003 Re: logical xor | ||||
---|---|---|---|---|
| ||||
Posted in reply to Antti Sykäri | > There's one reason I can think of:
>
> - There wouldn't be the periodical question "Why is there no ^^?" on the
> newsgroup
Technically, || and && are not logical operators but control flow operators, similar to "a ? b : c"
(x || y) => (x ? true : y)
(x && y) => (x ? y : false)
It is more clear in Ada, where these operators are called "short-circuit
control forms", and have more descriptive names:
|| => "or else"
&& => "and then"
|
Copyright © 1999-2021 by the D Language Foundation