Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: pushtaev [...] cpan.org
Cc: ribasushi [...] leporine.io
AdminCc:

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



Subject: Try string, not block
I have an issue with using Try::Tiny which I described on Perl Monks: http://www.perlmonks.org/?node_id=993171 Do you think it's reasonable to add something like try_string {...} in Try::Tiny? Will be it added in module if I implement this feature? It's quite usefull, but it (maybe) makes Try::Tiny a bit less tiny.
Subject: Re: [rt.cpan.org #79666] Try string, not block
Date: Sat, 15 Sep 2012 14:32:34 -0500
To: Pushtaev Vadim via RT <bug-Try-Tiny [...] rt.cpan.org>
From: Jesse Luehrs <doy [...] tozt.net>
On Sat, Sep 15, 2012 at 03:29:26PM -0400, Pushtaev Vadim via RT wrote: Show quoted text
> Sat Sep 15 15:29:25 2012: Request 79666 was acted upon. > Transaction: Ticket created by PUSHTAEV > Queue: Try-Tiny > Subject: Try string, not block > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: pushtaev@cpan.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=79666 > > > > I have an issue with using Try::Tiny which I described on Perl Monks: > http://www.perlmonks.org/?node_id=993171 > > Do you think it's reasonable to add something like try_string {...} in > Try::Tiny? Will be it added in module if I implement this feature? > > It's quite usefull, but it (maybe) makes Try::Tiny a bit less tiny.
This was considered when Try::Tiny was first being written, but the conclusion was that there is actually no way to do this safely, given limitations in perl itself. About the closest you're going to be able to get is something like "try { eval_closure(source => $foo) }" (using Eval::Closure). -doy
On Sat Sep 15 15:32:44 2012, doy@tozt.net wrote: Show quoted text
> > This was considered when Try::Tiny was first being written, but the > conclusion was that there is actually no way to do this safely, given > limitations in perl itself. About the closest you're going to be able
to Show quoted text
> get is something like "try { eval_closure(source => $foo) }" (using > Eval::Closure). > > -doy
Thanks, I like this Eval::Closure module. What about non-safe "try_string" function, like perl "eval" itself? You don't want to spread evil over the world? :)
Subject: Re: [rt.cpan.org #79666] Try string, not block
Date: Sat, 15 Sep 2012 14:42:45 -0500
To: Pushtaev Vadim via RT <bug-Try-Tiny [...] rt.cpan.org>
From: Jesse Luehrs <doy [...] tozt.net>
On Sat, Sep 15, 2012 at 03:40:06PM -0400, Pushtaev Vadim via RT wrote: Show quoted text
> Queue: Try-Tiny > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=79666 > > > On Sat Sep 15 15:32:44 2012, doy@tozt.net wrote:
> > > > This was considered when Try::Tiny was first being written, but the > > conclusion was that there is actually no way to do this safely, given > > limitations in perl itself. About the closest you're going to be able
> to
> > get is something like "try { eval_closure(source => $foo) }" (using > > Eval::Closure). > > > > -doy
> > Thanks, I like this Eval::Closure module. > > What about non-safe "try_string" function, like perl "eval" itself? You > don't want to spread evil over the world? :)
As I said, it's not possible in a general sense - note that Eval::Closure is limited to string eval of strings that return coderefs (the example I gave should really be something more along the lines of "try { eval_closure(source => "sub { $foo }")->() }"). Not all code can be wrapped in subs like that though. -doy
On Sat Sep 15 15:42:55 2012, doy@tozt.net wrote: Show quoted text
> On Sat, Sep 15, 2012 at 03:40:06PM -0400, Pushtaev Vadim via RT wrote:
> > Queue: Try-Tiny > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=79666 > > > > > On Sat Sep 15 15:32:44 2012, doy@tozt.net wrote:
> > > > > > This was considered when Try::Tiny was first being written, but the > > > conclusion was that there is actually no way to do this safely, given > > > limitations in perl itself. About the closest you're going to be able
> > to
> > > get is something like "try { eval_closure(source => $foo) }" (using > > > Eval::Closure). > > > > > > -doy
> > > > Thanks, I like this Eval::Closure module. > > > > What about non-safe "try_string" function, like perl "eval" itself? You > > don't want to spread evil over the world? :)
> > As I said, it's not possible in a general sense - note that > Eval::Closure is limited to string eval of strings that return coderefs > (the example I gave should really be something more along the lines of > "try { eval_closure(source => "sub { $foo }")->() }"). Not all code can > be wrapped in subs like that though. > > -doy
This shapes up to be a "wontfix" (I agree with the limitations being too severe to do properly). Someone with rights please reject this.
If someone can come up with an implementation that actually works, feel free to reopen this ticket, but I'm not particularly hopeful.