Re: XOR does not work that way.

2009-07-03 Thread Larry Wall
On Fri, Jul 03, 2009 at 09:40:12AM +0200, TSa wrote: > I see. But I wouldn't make that an exception but ^^ returns a tristate > value instead of boolean. The third state besides True and False is > TooMany that evaluates to False in boolean context. But ^^ can react > to it as you describe. That so

Re: XOR does not work that way.

2009-07-03 Thread TSa
HaloO, Martin D Kealey wrote: Assuming you meant "^^" rather than "&&", then under my proposal, that's not the case. Of course! Silly me, sorry. In particular, True ^^ True evaluates to TooManyException. If that exception is implicitly thrown, then that's what you get from the whole express

Re: XOR does not work that way.

2009-07-02 Thread Martin D Kealey
On Thu, 2 Jul 2009, TSa wrote: > Martin D Kealey wrote: > > This solves both the human expectation ("Would you like wine or beer or > > juice?" "Beer and juice please" "Sorry...") and the associativity > > problem: (a ^^ b) ^^ (c ^^ d) == a ^^ (b ^^ (c ^^ d)). > > I don't understand how the associ

Re: XOR does not work that way.

2009-07-02 Thread yary
On Thu, Jul 2, 2009 at 9:01 AM, yary wrote: > On Thu, Jul 2, 2009 at 8:58 AM, TSa wrote: >>... unless list associative operators somehow flatten the >> parens away and therefore see a single list of three values instead of >> two consecutive lists of two items. > > that's exactly what list associat

Re: XOR does not work that way.

2009-07-02 Thread yary
On Thu, Jul 2, 2009 at 8:58 AM, TSa wrote: >... unless list associative operators somehow flatten the > parens away and therefore see a single list of three values instead of > two consecutive lists of two items. that's exactly what list associative does, it feeds an arbitrarily long list of value

Re: XOR does not work that way.

2009-07-02 Thread TSa
HaloO, Martin D Kealey wrote: This solves both the human expectation ("Would you like wine or beer or juice?" "Beer and juice please" "Sorry...") and the associativity problem: (a ^^ b) ^^ (c ^^ d) == a ^^ (b ^^ (c ^^ d)). I don't understand how the associativity problem is solved when we use

Re: XOR does not work that way.

2009-06-24 Thread Patrick R. Michaud
On Thu, Jun 25, 2009 at 02:47:55PM +1000, Timothy S. Nelson wrote: > What would happen if we had an operator that returned the number of > true values? Say we call it "boolean plus", or "bop". ...why an operator? sub bop(*...@values) { + grep { $_ }, @values } > To give one exa

Re: XOR does not work that way.

2009-06-24 Thread Timothy S. Nelson
I'm just thinking out loud in this e-mail, trying to generate alternatives. What would happen if we had an operator that returned the number of true values? Say we call it "boolean plus", or "bop". To give one example: 1 bop 3 = 2 Say we're looking at: ($x > 1) bop 3 bop (

Re: XOR does not work that way.

2009-06-24 Thread Martin D Kealey
On Wed, Jun 24, 2009 at 10:35, John Macdonald wrote: > Which means that short-circuiting is not right here - it must > go through the entire list to determine whether there are zero > true selections, find the first of exactly one true selections, > or die if there are more than one true selection

Re: XOR does not work that way.

2009-06-24 Thread John Macdonald
On Wed, Jun 24, 2009 at 11:10:39AM -0700, Jon Lang wrote: > On Wed, Jun 24, 2009 at 10:35 AM, John Macdonald wrote: > > On Tue, Jun 23, 2009 at 07:51:45AM +1000, Damian Conway wrote: > >> Perl 6's approach to xor is consistent with the linguistic sense of > >> 'xor' ("You may have a soup (x)or a sa

Re: XOR does not work that way.

2009-06-24 Thread Jon Lang
On Wed, Jun 24, 2009 at 10:35 AM, John Macdonald wrote: > On Tue, Jun 23, 2009 at 07:51:45AM +1000, Damian Conway wrote: >> Perl 6's approach to xor is consistent with the linguistic sense of >> 'xor' ("You may have a soup (x)or a salad (x)or a cocktail"), [ ... ] > > That choice tends to mean "exa

Re: XOR does not work that way.

2009-06-24 Thread John Macdonald
On Wed, Jun 24, 2009 at 01:35:25PM -0400, John Macdonald wrote: > On Tue, Jun 23, 2009 at 07:51:45AM +1000, Damian Conway wrote: > > Perl 6's approach to xor is consistent with the linguistic sense of > > 'xor' ("You may have a soup (x)or a salad (x)or a cocktail"), [ ... ] > > That choice tends t

Re: XOR does not work that way.

2009-06-24 Thread John Macdonald
On Tue, Jun 23, 2009 at 07:51:45AM +1000, Damian Conway wrote: > Perl 6's approach to xor is consistent with the linguistic sense of > 'xor' ("You may have a soup (x)or a salad (x)or a cocktail"), [ ... ] That choice tends to mean "exactly one", rather than "the first one the waiter hears". (A go

Re: XOR does not work that way.

2009-06-23 Thread Brandon S. Allbery KF8NH
On Jun 22, 2009, at 19:12 , Minimiscience wrote: On Jun 22, 2009, at 5:51 PM, Damian Conway wrote: Perl 6's approach to xor is consistent with the linguistic sense of 'xor' ("You may have a soup (x)or a salad (x)or a cocktail"), and also with the IEEE 91 standard for logic gates. I don't th

Re: XOR does not work that way.

2009-06-22 Thread Jon Lang
Take a look at the page to which Damian provided a link. You'll find that XOR does indeed correspond to the definition being used by Perl 6, as well as the natural language meaning. What other languages call XOR is actually an "odd parity check". As I suggested above, I think that Perl 6 already

Re: XOR does not work that way.

2009-06-22 Thread Darren Duncan
Mark J. Reed wrote: All of which is just by way of agreeing with Jon: formal logic is not the primary motivator behind Perl's design. So while it should be considered, it's not a knockout punch to say "but logic doesn't work that way." I think another thing to consider is a survey of the variou

Re: XOR does not work that way.

2009-06-22 Thread Mark J. Reed
> On Mon, Jun 22, 2009 at 4:12 PM, Minimiscience wrote: > I don't think natural language -- especially the abomination that is English > -- is the best guide for understanding logical operations (why, yes, I *do* > speak Lojban; how did you know?). To which Jon Lang replied: > You're aware that Pe

Re: XOR does not work that way.

2009-06-22 Thread Jon Lang
On Mon, Jun 22, 2009 at 4:12 PM, Minimiscience wrote: > On Jun 22, 2009, at 5:51 PM, Damian Conway wrote: >> >> Perl 6's approach to xor is consistent with the linguistic sense of >> 'xor' ("You may have a soup (x)or a salad (x)or a cocktail"), and also >> with the IEEE 91 standard for logic gates.

Re: XOR does not work that way.

2009-06-22 Thread Minimiscience
On Jun 22, 2009, at 5:51 PM, Damian Conway wrote: Perl 6's approach to xor is consistent with the linguistic sense of 'xor' ("You may have a soup (x)or a salad (x)or a cocktail"), and also with the IEEE 91 standard for logic gates. I don't think natural language -- especially the abomination th

Re: XOR does not work that way.

2009-06-22 Thread Darren Duncan
Damian Conway wrote: Perl 6's approach to xor is consistent with the linguistic sense of 'xor' ("You may have a soup (x)or a salad (x)or a cocktail"), and also with the IEEE 91 standard for logic gates. See: http://ozark.hendrix.edu/~burch/logisim/docs/2.1.0/libs/gates/xor.html for a concis

Re: XOR does not work that way.

2009-06-22 Thread Damian Conway
Perl 6's approach to xor is consistent with the linguistic sense of 'xor' ("You may have a soup (x)or a salad (x)or a cocktail"), and also with the IEEE 91 standard for logic gates. See: http://ozark.hendrix.edu/~burch/logisim/docs/2.1.0/libs/gates/xor.html for a concise explanation of both t

Re: XOR does not work that way.

2009-06-22 Thread yary
I had a bit of a problem when first encountering xor with more than two operands as well. It made sense after I thought about it linguistically instead of mathematically. When speaking people often use a string of "or"s to mean "pick one and only one of these choices, the the exclusion of all other

XOR does not work that way.

2009-06-22 Thread Minimiscience
S03 describes ^^ as a "short‐circuit exclusive‐or" operator which returns true if & only if exactly one operand is true, short circuiting after encountering two true values. However, this definition is only consistent with the mathematical definition of XOR when the operation is being perf