How to capture an div 0 exception

2016-05-18 Thread Richard Hainsworth
I want to capture a divide by 0 exception and replace the value with another. Here is the code I tried: use v6; my $d = 1; my $e = 2; my $f = 0; #my $r; my $r = 5; CATCH { # when X::AdHoc { when Exception { .Str.say; # $r = 5; .resume } } $r = try { ( $d + $e ) / $f; };

Re: How to capture an div 0 exception

2016-05-18 Thread mt1957
On 18-05-16 13:07, Richard Hainsworth wrote: use v6; my $d = 1; my $e = 2; my $f = 0; #my $r; my $r = 5; CATCH { # when X::AdHoc { when Exception { .Str.say; # $r = 5; .resume } } $r = try { ( $d + $e ) / $f; }; # my $r = try EVAL ' ( 1 + 2 ) /0 '; say "r is $r"; Hi Ric

Re: How to capture an div 0 exception

2016-05-18 Thread Moritz Lenz
On 05/18/2016 01:39 PM, mt1957 wrote: On 18-05-16 13:07, Richard Hainsworth wrote: use v6; my $d = 1; my $e = 2; my $f = 0; #my $r; my $r = 5; CATCH { # when X::AdHoc { when Exception { .Str.say; # $r = 5; .resume } } $r = try { ( $d + $e ) / $f; }; # my $r = try EVAL '

[perl #128173] [LTA ERROR] .polymod on Int with non-Int divisors

2016-05-18 Thread via RT
# New Ticket Created by Zoffix Znet # Please include the string: [perl #128173] # in the subject line of all future correspondence about this issue. # https://rt.perl.org/Ticket/Display.html?id=128173 > When .polymod on an Int invocan is called with a non-Int divisor, the error message is v

Re: How to capture an div 0 exception

2016-05-18 Thread Richard Hainsworth
Marcel and Moritz, Thank you for the fast response. I have been experimenting with the code you sent, but still do not understand something. To illustrate, here is another snippet: use v6; my $r; for 0..4 -> $s { { $r = 5 / (3 - $s); say "At line $?LINE r is $r"; CATCH {

[perl #128175] Potential For Infinite Loop in Real .polymod Due To Floating Point Math Imprecision

2016-05-18 Thread via RT
# New Ticket Created by Zoffix Znet # Please include the string: [perl #128175] # in the subject line of all future correspondence about this issue. # https://rt.perl.org/Ticket/Display.html?id=128175 > Current implementation of .polymod on Reals with lazy list divisors as arguments checks f

[perl #128176] [BUG] .polymod implementation assumes all lazy lists are infinite

2016-05-18 Thread via RT
# New Ticket Created by Zoffix Znet # Please include the string: [perl #128176] # in the subject line of all future correspondence about this issue. # https://rt.perl.org/Ticket/Display.html?id=128176 > When given a lazy list as the argument, .polymod divides until the original number given

Re: How to capture an div 0 exception

2016-05-18 Thread mt1957
Hi Richard, This has something to do with lazy evaluation. It triggers the calculation when it wants to show the value in $r. So commenting out the first 'say' will error on the second with the shown response. The CATCH is not at the same scope than the second 'say' statement so there you get

Re: How to capture an div 0 exception

2016-05-18 Thread Brandon Allbery
On Wed, May 18, 2016 at 11:27 AM, mt1957 wrote: > This has something to do with lazy evaluation. It triggers the calculation > when it wants to show the value in $r. IIRC it doesn't throw, it returns a Failure (deferred/lazy exception that throws when accessed). -- brandon s allbery kf8nh

Re: How to capture an div 0 exception

2016-05-18 Thread Brandon Allbery
On Wed, May 18, 2016 at 11:29 AM, Brandon Allbery wrote: > On Wed, May 18, 2016 at 11:27 AM, mt1957 wrote: > >> This has something to do with lazy evaluation. It triggers the >> calculation when it wants to show the value in $r. > > > IIRC it doesn't throw, it returns a Failure (deferred/lazy ex

[perl #128162] [RFC] Ranges that start with an empty string produce lots of empty strings (‘’…‘WAT’)

2016-05-18 Thread Will Coleda via RT
On Mon May 16 16:55:40 2016, alex.jakime...@gmail.com wrote: > Code: > dd (‘’..‘WAT’)[^20] > > Result: > ("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", > "", "", "") > > > I don't know what would be the right behavior, but an infinite list of > empty strings is probably the

[perl #125182] bufs need .push

2016-05-18 Thread Will Coleda via RT
Tests in S03-operators/buf.t hoelzro++ -- Will "Coke" Coleda

[perl #125182] bufs need .push

2016-05-18 Thread Will Coleda via RT
Tests in S03-operators/buf.t hoelzro++ -- Will "Coke" Coleda

[perl #128181] [RFC] Changed behavior after v6.c: using “last” inside “grep” (say ^∞ .grep: { last })

2016-05-18 Thread via RT
# New Ticket Created by Alex Jakimenko # Please include the string: [perl #128181] # in the subject line of all future correspondence about this issue. # https://rt.perl.org/Ticket/Display.html?id=128181 > Code: say ^∞ .grep: { last } Result (2016.01): () Result (HEAD): (0 1 2 3 4 5 6 7 8 9

Re: How to capture an div 0 exception

2016-05-18 Thread Richard Hainsworth
On Wednesday, May 18, 2016 11:40 PM, Brandon Allbery wrote: On Wed, May 18, 2016 at 11:29 AM, Brandon Allbery > wrote: On Wed, May 18, 2016 at 11:27 AM, mt1957 mailto:mt1...@gmail.com>> wrote: This has something to do with lazy evaluation. It triggers the