Hi all,
For the next version of Inline::Java I want to implement Java exceptions in
Perl, i.e. exception
throw in Java translate to Perl. To mimic the Java functionality thoroughly,
IO need to implement
a try / catch construct. This is the most Java-like "syntax" I could come up
with (and the cleanest):
------8<------
# some Java object for which method "f" throws an exception
my $t = new t9() ;
my $msg = '' ;
try sub {
$t->f() ;
} ;
catch "java.io.IOException" => sub {
my $e = shift ;
$msg = $e->getMessage() . "io" ;
} ;
catch "java.lang.Exception" => sub {
my $e = shift ;
$msg = $e->getMessage() ;
} ;
------8<------
'try' and 'catch' are export_ok methods in the Inline::Java package that
basically receive
anonymous subroutines (among others) as arguments.
Does anyone have any comments/suggestions on any other "nice looking" ways
to implements these constructs?
Thanks,
Patrick
-------------------------
Patrick LeBoutillier
Laval, Quebec, Canada