Tony Olekshy wrote:

> There you have it.  That's why RFC 88 uses structured data for $@.

That's a good argument, one that I have no quarrel with.  As an
enhancement to eval/die, this would make it more flexible for checking
conditions.  And with appropriate stringification, it is upward
compatible with the current uses of $@ by eval/die.

Transliterating $@ to whatever would be used equivalently for an
exception mechanism, I still agree that structured data is good.

> Now, here's an alternative that may keep everyone happy.  In
> addition to whatever RFC 88 does now, change this rule about how
> die behaves:
>
>     If passed a single argument that isa "Exception", raise it as
>     the new exception and die in the fashion that Perl 5 does.
>
>     Otherwise, the arguments are stringified and joined with C<''>
>     (as in Perl 5), the resulting string is wrapped up in a new
>     Exception object (setting the message instance variable to said
>     string), and the new Exception object is raised.
>
> to read like this:
>
>     If passed a single argument that isa "Exception", raise it as
>     the new exception and die in the fashion that Perl 5 does.
>
>     Otherwise, the arguments are stringified and joined with C<''>
>     (as in Perl 5), the resulting string is wrapped up in a new
>     Exception object (setting the message instance variable to said
>     string), the original unstringified arguments are saved in a
>     list ref in the object's C<args> instance variable, and the new
>     Exception object is raised.
>
> then you can say C<die qw(A B C)>, and the following tests both work:
>
>     catch $@->args->[1] eq "B" => { ... }
>
>     catch $@ =~ /B/ => { ... }
>
> Yours, &c, Tony Olekshy

We're getting closer and closer.  Now we just need a magic array such
that before the first catch clause is executed, it gets assigned the
contents of @{$@->args}.  I guess (per your other postings), that could
be achieved via RFC 88 functionality by:

      try on_catch_enter => sub { @! = @{$@->args}; return true; },
      { ...
      }
      catch $![0] == 53 => { ... };

On the other hand, that would conflict with your use of on_catch_enter
for other purposes, but I use it to demonstrate the functionality I'd
like to see: that catch can directly access the list of arguments passed
to throw, whatever they are.  I'm not sure I fully understand the way the
on_catch_enter hook works or is set, and I don't want to have to actually
do this to achieve the goal.

--
Glenn
=====
There  are two kinds of people, those
who finish  what they start,  and  so
on...                 -- Robert Byrne



____________NetZero Free Internet Access and Email_________
Download Now     http://www.netzero.net/download/index.html
Request a CDROM  1-800-333-3633
___________________________________________________________

Reply via email to