On 1/19/06, DZ-Jay <[EMAIL PROTECTED]> wrote:
> Hello:
>         This might sound like a stupid question,


I'm guessing that your current syntax works because
you have declared prototypes for CATCH and POST
of (\&) which coerces the block given as their arguments
into a coderef?

A pretty big syntax change you are proposing, and perl 5
isn't going to swallow it all with perl 5 mechanisms, not counting
source filtering.

By cluttering up your syntax with more perl5 to frame the
different parts, you can get all the features you want but
it isn't as nice.  Imagine if you will:


use DZJay::try;  # exports try(@)

sub do_something{
     ...
     my $local_variable; # have to follow p5 scoping, sorry
     try TRY => sub {
                   ...  # this is what we are trying
     }, CATCH => sub {
                   ... # this is what we are catching,
                       # $@ is available here
     }, POST => sub {
                   ... # happens after TRY, exception or no
     };

};

__END__

that is good perl 5, and doesn't care about the order of the arguments.

An obvious extension would be

     }, CATCH => [ qr/froobzoggle/,
        sub {
             ... # code to handle froobzoggle errors
     }],CATCH => sub { ... }; # default catch


and you quickly get into performance/feature tradeoffs.

And actually having code using your module be tighter than
the same code written with eval-block, die, and direct matching
against $@ instead of abstracting all of those behind an
equivalently complex interface, just to use differnt terms,
good luck.

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to