Peter Scott wrote:
>
> At 10:13 AM 8/23/00 -0600, Tony Olekshy wrote:
>
> >Making throw a method of Exception just means we don't have to say
> >
> >     throw Exception->new("Can't foo.", tag => "ABC.1234", ...);
> >
> >and it means throw isn't a new keyword, and that throw $@ can,
> >invoked now as an instance method rather than a constructor,
> >do the right thing.
> >
> >However, a bare C<throw> doesn't make sense now, because it's a
> >method.
>
> Like I said before, don't let that stop you if you want to make it
> do something; you can just make throw a core function as well as a
> class method.

Yes, clearly. The only difference is that an extra comma is required,
as in:
                ----v
    throw Exception => "Can't foo.", tag => "ABC.1234";

    sub throw
    {
        my ($C, $msg, %opts) = @_;

        die $C->new($msg, %opts) unless ref $C;

        die $C if $C->isa("Exception");

        die new Exception::NotException "...",
                    debug => join(", ", @_);
        }

And, who knows what syntax options will be available with Perl 6?

Yours, &c, Tony Olekshy

Reply via email to