Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: 'xor' operator is not a sibling to 'or' and 'and'? (short-circuit and other languages.)

by LanX (Saint)
on Dec 19, 2019 at 17:53 UTC ( [id://11110400]=note: print w/replies, xml ) Need Help??


in reply to 'xor' operator is not a sibling to 'or' and 'and'?

This WP article: Short-circuit evaluation

covers most if not all aspects of this thread and lists languages with similar behavior. (See table entries marked "last value", like Perl, Ruby, JS, Python,...)

Quotes:

  • In loosely typed languages that have more than the two truth-values True and False, short-circuit operators may return the last evaluated subexpression. The expression x and y is equivalent to y if x else x; the expression x or y is equivalent to x if x else y (without evaluating x twice). This is called "last value" in the table below.
  • For some Boolean operations, like exclusive or (XOR), it is not possible to short-circuit, because both operands are always required to determine the result.

see also Re^5: 'xor' operator is not a sibling to 'or' and 'and'?

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

  • Comment on Re: 'xor' operator is not a sibling to 'or' and 'and'? (short-circuit and other languages.)
  • Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11110400]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-16 17:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found