Skip Menu |

This queue is for tickets about the Try-Tiny CPAN distribution.

Report information
The Basics
Id: 67801
Status: rejected
Priority: 0/
Queue: Try-Tiny

People
Owner: Nobody in particular
Requestors: hanenkamp [...] cpan.org
Cc:
AdminCc:

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



Subject: Try::Tiny has an unfavorable interaction with given-when
I don't know what the fix is, but this program does not work as I expect. I would expect the output to be "bad stuff at try.pl line 12" but... #!/usr/bin/perl use 5.10.1; use strict; use warnings; use Try::Tiny; my $x = "neither here nor there"; given ($x) { when ("neither here nor there") { try { die "bad stuff"; say "good stuff"; } catch { say $_; }; } } # This program outputs: # # neither here nor there
Subject: Re: [rt.cpan.org #67801] Try::Tiny has an unfavorable interaction with given-when
Date: Wed, 27 Apr 2011 17:08:43 -0400
To: Andrew Sterling Hanenkamp via RT <bug-Try-Tiny [...] rt.cpan.org>
From: Ricardo Signes <rjbs [...] cpan.org>
* Andrew Sterling Hanenkamp via RT <bug-Try-Tiny@rt.cpan.org> [2011-04-27T16:54:29] Show quoted text
> my $x = "neither here nor there"; > given ($x) { > when ("neither here nor there") { > try { > die "bad stuff"; > say "good stuff"; > } > > catch { > say $_; > }; > } > } > > # This program outputs: > # > # neither here nor there
Unfortunately, given/when topicalizes with a *lexical* $_, which is always prioritized over the *global* (dynamic) $_ that is provided by try/catch, and obviously try/catch can't affect the lexical $_ because its machinery is not in the same lexical scope. push @reasons_not_to_use_givenwhen, $that; -- rjbs
Yeah, what rjbs said, there's nothing we can do about this. This is a duplicate of https://rt.cpan.org/Ticket/Display.html?id=65603 by the way, which includes some possible workarounds.
Subject: Re: [rt.cpan.org #67801] Try::Tiny has an unfavorable interaction with given-when
Date: Thu, 28 Apr 2011 09:10:57 -0500
To: bug-Try-Tiny [...] rt.cpan.org
From: Sterling Hanenkamp <sterling [...] hanenkamp.com>
Perhaps a CAVEATS section in the docs then so others who aren't intimate with the lexical-ness of given-when won't be caught unaware as I was? On Wed, Apr 27, 2011 at 4:48 PM, Jesse Luehrs via RT < bug-Try-Tiny@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=67801 > > > Yeah, what rjbs said, there's nothing we can do about this. This is a > duplicate of https://rt.cpan.org/Ticket/Display.html?id=65603 by the > way, which includes some possible workarounds. >
-- Andrew Sterling Hanenkamp sterling@hanenkamp.com 785.370.4454
Subject: Re: [rt.cpan.org #67801] Try::Tiny has an unfavorable interaction with given-when
Date: Thu, 28 Apr 2011 10:35:23 -0400
To: "sterling [...] hanenkamp.com via RT" <bug-Try-Tiny [...] rt.cpan.org>
From: Ricardo Signes <rjbs [...] cpan.org>
* "sterling@hanenkamp.com via RT" <bug-Try-Tiny@rt.cpan.org> [2011-04-28T10:11:08] Show quoted text
> Queue: Try-Tiny > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=67801 > > > Perhaps a CAVEATS section in the docs then so others who aren't intimate > with the lexical-ness of given-when won't be caught unaware as I was?
That is already present in http://search.cpan.org/dist/Try-Tiny/lib/Try/Tiny.pm Quote: Lexical $_ may override the one set by catch. For example Perl 5.10's given form uses a lexical $_, creating some confusing behavior: -- rjbs
Subject: Re: [rt.cpan.org #67801] Try::Tiny has an unfavorable interaction with given-when
Date: Thu, 28 Apr 2011 10:43:41 -0500
To: bug-Try-Tiny [...] rt.cpan.org
From: Sterling Hanenkamp <sterling [...] hanenkamp.com>
Wow, I am blind. I do not know how I missed that. Nevermind. All's well. On Thu, Apr 28, 2011 at 9:35 AM, Ricardo Signes via RT < bug-Try-Tiny@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=67801 > > > * "sterling@hanenkamp.com via RT" <bug-Try-Tiny@rt.cpan.org> > [2011-04-28T10:11:08]
> > Queue: Try-Tiny > > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=67801 > > > > > Perhaps a CAVEATS section in the docs then so others who aren't intimate > > with the lexical-ness of given-when won't be caught unaware as I was?
> > That is already present in > http://search.cpan.org/dist/Try-Tiny/lib/Try/Tiny.pm > > Quote: > > Lexical $_ may override the one set by catch. > > For example Perl 5.10's given form uses a lexical $_, creating some > confusing > behavior: > > > -- > rjbs > >
-- Andrew Sterling Hanenkamp sterling@hanenkamp.com 785.370.4454