Skip Menu |

This queue is for tickets about the List-Compare CPAN distribution.

Report information
The Basics
Id: 85815
Status: rejected
Priority: 0/
Queue: List-Compare

People
Owner: jkeenan [...] cpan.org
Requestors: nenad.noveljic [...] vontobel.ch
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: List::Compare::Functional
Date: Mon, 3 Jun 2013 07:45:45 +0000
To: <bug-List-Compare [...] rt.cpan.org>, <jkeenan [...] cpan.org>
From: <nenad.noveljic [...] vontobel.ch>
Hi, get_unique raises error if: - the left array has less elements than the right - the function is included in fatal. The test case: use List::Compare::Functional qw(get_unique) ; use English ; use Fatal qw(get_unique) ; my $l = [qw(a ) ] ; my $r = [qw(a b ) ] ; eval { my @dist = get_unique( [$l , $r ] ) ; } ; if ($EVAL_ERROR) { print "$EVAL_ERROR\n" ; } The error: Can't get_unique(ARRAY(0x81904a8)), $! is "" at (eval 6) line 4 main::__ANON__('ARRAY(0x81904a8)') called at /export/home/oracle/local/dev/workspace/DBA/libperl/Test.pl line 16 Regards, Nenad Noveljic Show quoted text
____________________________________________________ Please consider the environment before printing this e-mail. Bitte denken Sie an die Umwelt, bevor Sie dieses E-Mail drucken. <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css">p { font-family: Arial;font-size:9pt }</style> </head> <body> <p> <br>Important Notice</br> <br>This message is intended only for the individual named. It may contain confidential or privileged information. If you are not the named addressee you should in particular not disseminate, distribute, modify or copy this e-mail. Please notify the sender immediately by e-mail, if you have received this message by mistake and delete it from your system.</br> <br>E-mail transmission may not be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete. Also processing of incoming e-mails cannot be guaranteed. All liability of the Vontobel Group and its affiliates for any damages resulting from e-mail use is excluded. You are advised that urgent and time sensitive messages should not be sent by e-mail and if verification is required please request a printed version.<br/> </p> </body> </html>
On Mon Jun 03 03:46:07 2013, nenad.noveljic@vontobel.ch wrote: Show quoted text
> Hi, > > get_unique raises error if: > - the left array has less elements than the right > - the function is included in fatal. > > The test case: > > use List::Compare::Functional qw(get_unique) ; > use English ; > > use Fatal qw(get_unique) ; > > my $l = [qw(a ) ] ; > my $r = [qw(a b ) ] ; > > eval { > my @dist = get_unique( [$l , $r ] ) ; > } ; > if ($EVAL_ERROR) { > print "$EVAL_ERROR\n" ; > } > > The error: > Can't get_unique(ARRAY(0x81904a8)), $! is "" at (eval 6) line 4 > main::__ANON__('ARRAY(0x81904a8)') called at > /export/home/oracle/local/dev/workspace/DBA/libperl/Test.pl line 16 > > Regards, > > Nenad Noveljic >
Nenad, Thank you for this report. However, I do not feel that there is any error in List::Compare::Functional here. The error is a mis-application of the Fatal module. The first thing to note about Fatal is that it is obsolete. Its documentation in the version distributed with Perl 5.18.0 contains this advisory under the section "BEST PRACTICE": ##### B<Fatal has been obsoleted by the new L<autodie> pragma.> Please use L<autodie> in preference to C<Fatal>. L<autodie> supports lexical scoping, throws real exception objects, and provides much nicer error messages. ##### But even if Fatal were still a valid practice, you are not using it correctly. The documentation describes Fatal's purpose as: ##### C<Fatal> provides a way to conveniently replace functions which normally return a false value when they fail with equivalents which raise exceptions if they are not successful. ##### Fatal was mainly intended to reduce the amount of keystrokes needed to catch exceptions for built-in functions like 'open' and 'close'. (See 'perldoc Fatal' for examples.) Note that these functions are usually wrappers around system calls, which is why it is imperative that their failures be detected. In this instance, List::Compare::Functional::get_unique() returned a false value -- an empty list -- but it *did not fail*. In the example you provided, there are no elements which appear at least once only in the left-hand list. Since it is perfectly legitimate for get_unique() to return a false value, there is no basis for wrapping it via Fatal. Thank you very much. Jim Keenan
Subject: 85815_get_unique.pl
#!/usr/local/bin/perl use strict; use warnings; use 5.010_001; use Data::Dumper;$Data::Dumper::Indent=1; use Carp; use List::Compare::Functional qw(get_unique); use English; # Get those items which appear (at least once) only in the first list. # @Lonly = get_unique( [ \@Llist, \@Rlist ] ); my $l = [qw(a ) ] ; my $r = [qw(a b ) ] ; my @Lonly; @Lonly = get_unique( [ $l, $r ] ); say STDERR Dumper \@Lonly; @Lonly = get_unique( { lists => [ $l, $r ] } ); say STDERR Dumper \@Lonly; { @Lonly = get_unique( [ $l, $r ] ); say STDERR Dumper \@Lonly; say STDERR "<$@>"; } { @Lonly = get_unique( { lists => [ $l, $r ] } ); say STDERR Dumper \@Lonly; say STDERR "<$@>"; } ##### { @Lonly = get_unique( [ $l, $r ] ); say STDERR Dumper \@Lonly; say STDERR "<$EVAL_ERROR>"; } { @Lonly = get_unique( { lists => [ $l, $r ] } ); say STDERR Dumper \@Lonly; say STDERR "<$EVAL_ERROR>"; }
Subject: RE: [rt.cpan.org #85815] List::Compare::Functional
Date: Mon, 10 Jun 2013 06:55:23 +0000
To: <bug-List-Compare [...] rt.cpan.org>
From: <nenad.noveljic [...] vontobel.ch>
Hi Jim, Thanks a lot for the clarification. Kind regards, Nenad Show quoted text
-----Original Message----- From: James E Keenan via RT [mailto:bug-List-Compare@rt.cpan.org] Sent: Sonntag, 9. Juni 2013 17:50 To: Noveljic Nenad Subject: [rt.cpan.org #85815] List::Compare::Functional <URL: https://rt.cpan.org/Ticket/Display.html?id=85815 > On Mon Jun 03 03:46:07 2013, nenad.noveljic@vontobel.ch wrote:
> Hi, > > get_unique raises error if: > - the left array has less elements than the right > - the function is included in fatal. > > The test case: > > use List::Compare::Functional qw(get_unique) ; > use English ; > > use Fatal qw(get_unique) ; > > my $l = [qw(a ) ] ; > my $r = [qw(a b ) ] ; > > eval { > my @dist = get_unique( [$l , $r ] ) ; > } ; > if ($EVAL_ERROR) { > print "$EVAL_ERROR\n" ; > } > > The error: > Can't get_unique(ARRAY(0x81904a8)), $! is "" at (eval 6) line 4 > main::__ANON__('ARRAY(0x81904a8)') called at > /export/home/oracle/local/dev/workspace/DBA/libperl/Test.pl line 16 > > Regards, > > Nenad Noveljic >
Nenad, Thank you for this report. However, I do not feel that there is any error in List::Compare::Functional here. The error is a mis-application of the Fatal module. The first thing to note about Fatal is that it is obsolete. Its documentation in the version distributed with Perl 5.18.0 contains this advisory under the section "BEST PRACTICE": ##### B<Fatal has been obsoleted by the new L<autodie> pragma.> Please use L<autodie> in preference to C<Fatal>. L<autodie> supports lexical scoping, throws real exception objects, and provides much nicer error messages. ##### But even if Fatal were still a valid practice, you are not using it correctly. The documentation describes Fatal's purpose as: ##### C<Fatal> provides a way to conveniently replace functions which normally return a false value when they fail with equivalents which raise exceptions if they are not successful. ##### Fatal was mainly intended to reduce the amount of keystrokes needed to catch exceptions for built-in functions like 'open' and 'close'. (See 'perldoc Fatal' for examples.) Note that these functions are usually wrappers around system calls, which is why it is imperative that their failures be detected. In this instance, List::Compare::Functional::get_unique() returned a false value -- an empty list -- but it *did not fail*. In the example you provided, there are no elements which appear at least once only in the left-hand list. Since it is perfectly legitimate for get_unique() to return a false value, there is no basis for wrapping it via Fatal. Thank you very much. Jim Keenan
____________________________________________________ Please consider the environment before printing this e-mail. Bitte denken Sie an die Umwelt, bevor Sie dieses E-Mail drucken. Important Notice This message is intended only for the individual named. It may contain confidential or privileged information. If you are not the named addressee you should in particular not disseminate, distribute, modify or copy this e-mail. Please notify the sender immediately by e-mail, if you have received this message by mistake and delete it from your system. E-mail transmission may not be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete. Also processing of incoming e-mails cannot be guaranteed. All liability of the Vontobel Group and its affiliates for any damages resulting from e-mail use is excluded. You are advised that urgent and time sensitive messages should not be sent by e-mail and if verification is required please request a printed version.