develooper Front page | perl.perl5.porters | Postings from June 2022

Re: Core exception types [was: Re: Pre-RFC: Improve “wide character” warnings]

Thread Previous | Thread Next
From:
Yuki Kimoto
Date:
June 9, 2022 00:43
Subject:
Re: Core exception types [was: Re: Pre-RFC: Improve “wide character” warnings]
Message ID:
CAExogxOXQY3r_FTGFJWYbUsHLU_6vypODmqHy5ssNdMCUfqgeg@mail.gmail.com
2022-6-9 1:26 Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> wrote:

>
> > 3) use a new variable that holds the exception object and populate $@
> > with its string representation?
>
> This might actually be a thing.
>
> We can't change the existing behaviour of $@, but we *could* create
> some other variable, say, ${^EXCEPTION}, that would receive these new
> objects, and say that actually the catch var uses that instead:
>
>   try { ... }
>   catch($e) {
>     if($e isa X::Perl::ENOENT) { ... }
>   }
>
> These objects could then have whatever new interface we decided.
>
> If the user is still using "legacy" eval-and-$@ then they'll receive a
> stringified version of the object in that case, so as to not break
> legacy behaviour.
>
>
I feel good.

try - catch is yet experimental. In the only case of try - catch (remaining
of the behavior eval {}; if ($@) { } ), the content of "$e" can be changed.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About