Re: %% with zero denominator

2017-12-11 Thread Darren Duncan
On 2017-12-11 5:21 PM, Sean McAfee wrote: Well, /any/ function or operator that returns a boolean /could/ return a Failure instead of (or in addition to) False to provide additional information to those who want it, but if the condition is not really a Failure, wouldn't that be misleading? Like

Re: %% with zero denominator

2017-12-11 Thread Sean McAfee
On Mon, Dec 11, 2017 at 3:01 PM, wrote: > > On 2017-12-11 12:22 PM, Sean McAfee wrote: > >> Well, not really. I don't think x %% 0 should return a Failure at all. >> > > Is there a particular problem the current implementation fails to solve? > In boolean > context `x %% 0` *is* equivalent to Fa

Re: %% with zero denominator

2017-12-11 Thread zoffix
On 2017-12-11 12:22 PM, Sean McAfee wrote: Well, not really. I don't think x %% 0 should return a Failure at all. Is there a particular problem the current implementation fails to solve? In boolean context `x %% 0` *is* equivalent to False. The Failure carries additional information to th

Re: %% with zero denominator

2017-12-11 Thread Vittore Scolari
You might want to look at this discussion: http://www.perlmonks.org/?node_id=87384 by the way it seems like the Intel enginners agree with Perl 6 semantics: a modulo operation with MOD is undefined if the divisor is zero, with IDIV, the instruction used by modern gcc, it is an exception (interrup

Re: %% with zero denominator

2017-12-11 Thread Vittore Scolari
not what you think: module operator in % in perl6 is defined as $b - $a * floor($b / $a) On Mon, Dec 11, 2017 at 10:37 PM, Sean McAfee wrote: > On Mon, Dec 11, 2017 at 12:56 PM, Darren Duncan > wrote: > >> On 2017-12-11 12:22 PM, Sean McAfee wrote: >> >>> Well, not really. I don't think x %%

Re: %% with zero denominator

2017-12-11 Thread Sean McAfee
On Mon, Dec 11, 2017 at 12:56 PM, Darren Duncan wrote: > On 2017-12-11 12:22 PM, Sean McAfee wrote: > >> Well, not really. I don't think x %% 0 should return a Failure at all. >> >> 1 / 0 is an expression which can evaluate to no sensible value, so it >> makes >> sense to fail there. By the que

Re: %% with zero denominator

2017-12-11 Thread Darren Duncan
Putting aside the edge case of what to do when the divisor is zero, which could also be tested for prior to attempting to call the operator: An "is evenly divisible by" operator is an immensely useful one to have built-in to the language; not only is "x %% y" much more direct to the real questi

Re: %% with zero denominator

2017-12-11 Thread Vittore Scolari
I think that this stems from a confusion between the divisibility problem in integer number (on a ring) and the divisibility problem resolved by the perl6 %% operator. Personally I think that %% is useless while the former is useful and missing. But I have nothing against useless operators On Mon

Re: %% with zero denominator

2017-12-11 Thread Darren Duncan
On 2017-12-11 12:22 PM, Sean McAfee wrote: Well, not really. I don't think x %% 0 should return a Failure at all. 1 / 0 is an expression which can evaluate to no sensible value, so it makes sense to fail there. By the question "Is one divisible by zero?" has the simple answer "No." I strongl

Re: %% with zero denominator

2017-12-11 Thread Sean McAfee
On Mon, Dec 11, 2017 at 1:52 AM, Elizabeth Mattijsen wrote: > > On 11 Dec 2017, at 04:42, Sean McAfee wrote: > > The docs say a %% b is True if a % b is 0, so the error is as-designed, > at least. But mightn't it make more sense for %% to just return False when > given a second zero operand? A

Re: %% with zero denominator

2017-12-11 Thread Elizabeth Mattijsen
> On 11 Dec 2017, at 04:42, Sean McAfee wrote: > > I think of %% as being Perl 6's is-divisible-by operator, so I was a little > surprised to discover this behavior: > > > 1 %% 0 > Attempt to divide 1 by zero using infix:<%%> > in block at line 1 > > The docs say a %% b is True if a % b i

%% with zero denominator

2017-12-10 Thread Sean McAfee
I think of %% as being Perl 6's is-divisible-by operator, so I was a little surprised to discover this behavior: > 1 %% 0 Attempt to divide 1 by zero using infix:<%%> in block at line 1 The docs say a %% b is True if a % b is 0, so the error is as-designed, at least. But mightn't it make mor

[perl #69310] [BUG] No error when constructing a Rat with zero denominator, nothing happens when trying to print it in Rakudo

2009-09-23 Thread Carl Mäsak
# New Ticket Created by "Carl Mäsak" # Please include the string: [perl #69310] # in the subject line of all future correspondence about this issue. # http://rt.perl.org/rt3/Ticket/Display.html?id=69310 > rakudo: say 1/0; say "Alive"; say (1/0).Num rakudo 0eaf62: OUTPUT«Alive␤Divide by zero