I wonder if this would be useful? Nothing Perl-specific, but maybe to think about as Perl 6 approaches.

# pseudocode try { serve(); } bounce(Error::Return) { $rally++; } catch (Error::OutOfBounds){ new_point(); } sub serve { throw Error::OutOfBounds if int rand 10 <=1; lob Error::Return foreach (0..2); return "Advantage Caller"; }

The idea is that sometimes you definitely want to throw an error - there's no way to continue. On the other hand, you might just want to lob an error back to the caller, and let them decide if they want to go on. So then the caller could either catch the exception, or bounce it back - in which case the callee would continue executing as if nothing had happened.

Useful? Well, suppose you had a function to parse HTML. Your function hits some dodgy syntax. Should it give up or press on? Depends whether you're in strict mode or not.

Or... you read files in a directory tree, and then one of the needed files is missing. Is this a disaster, or do you just want to keep gathering up the information, but note that you missed a file?

# pseudocode sub dir_reader { # ... while (my ($curdir, $name) = next_in_tree()) { -e "$curdir/$name" or lob "Couldn't open file $name"; push @files, $name; } # ... return @files; } sub keep_on { try { dir_reader(@_) } bounce { /.*(\S+)$/; push @badfiles, $1;} } sub give_up { try { dir_reader(@_) } catch{ die "Couldn't open file $_"} }

Just a thought. It's a way to make communication between caller and callee a bit more flexible - even streamlike. I suspect someone is now going to point out that this violates fundamental design principles, or can be done easily using XOR and a box of matchsticks, but I thought it might be an interesting concept.
A massive flamewar beneath your chosen depth has not been shown here


In reply to In time for Wimbledon by dash2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.