Skip Menu |

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

Report information
The Basics
Id: 133090
Status: open
Priority: 0/
Queue: Syntax-Keyword-Try

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

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



Subject: Consider "else" block
Some syntax like try { ... } catch { ... } else { # code gets run if an exception wasn't thrown } could be handy. There's times I want to run something only on successful completion. Analogous to the two-argument ->then method on Futures. A contentious design point here is going to be the name. Python names it "else", but then Python also has "else" blocks on and for loops. I'd prefer not to reĆ¼se the "else" keyword here but instead invent a new one. I just don't have any good naming ideas. Internet Bikeshed Go! -- Paul Evans
A wildly alternative idea might be a `trial` keyword; which acts like a better-designed `eval`, returning the exception in addition to the list of values its code returns: my ($e, @results) = trial { ... } if(!$e) { ... code on success; can see @results } else { ... code on failure; can see $e } -- Paul Evans
It's the opposite of a "catch" block, so surely the only acceptable keyword for this is "fumble". :) Or now you have typed catch blocks, you could use explicit empty parentheses: catch () { ... } For a block that executes when you caught no exception.