develooper Front page | perl.perl5.porters | Postings from January 2021

Re: Adding a try/catch syntax to Perl

Thread Previous | Thread Next
From:
Philip R Brenan
Date:
January 22, 2021 20:42
Subject:
Re: Adding a try/catch syntax to Perl
Message ID:
CALhwFRnAwVxHDhLNxwVPBfVUpaD0UL1PhZg4nRD_9VLnJBE4zA@mail.gmail.com
Might it be better to have the exception in *$@* as "in the best it is"?
This would save updates to documentation, reduce user confusion and allow
the *($e)* to be dispensed with entirely in the most common use cases.  Of
course if one wishes to spend one's time needlessly typing parentheses, we
should all defend to the death the absolute right to do so. But for those
of us who prefer to get on with life and opt to use Perl because it is the
most expressive of languages, because it is not only not Java nor
Javascript but is in fact something altogether brighter and better, if a
small amount of programming could save so much effort, then  "If t'wer
done, when tis done, t'were well it were done quickly" would be seem to be
the best solution by far for the mortal rest of us.  "Chi vorrebbe
caricarsi di grossi fardelli ... "

On Fri, Jan 22, 2021 at 7:09 PM Paul "LeoNerd" Evans <leonerd@leonerd.org.uk>
wrote:

> On Fri, 22 Jan 2021 13:47:52 -0500
> Dan Book <grinnz@gmail.com> wrote:
>
> > The parentheses also enable future extensions with arbitrary syntax
> > such as typed dispatch.
>
> ^-- yes, that.
>
> I have been thinking several steps ahead here. While not a part of my
> *current* proposal for core, I do aim that one day we can
>
>   try { ... }
>   catch ($e isa MyApp::SomeWeirdException) { ... }
>   catch ($e isa Perl::X::ENOENT) { ... }
>   catch ($e) { default here }
>
> So the parens are necessary for those later forward steps.
>
> If you want to see the full and varied discussions about the history of
> that part of Syntax::Keyword::Try, see [while rt.cpan.org is still a
> thing]:
>
>   https://rt.cpan.org/Ticket/Display.html?id=123918
>
> --
> Paul "LeoNerd" Evans
>
> leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
> http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/
>


-- 
Thanks,

Phil <https://metacpan.org/author/PRBRENAN>

Philip R Brenan <https://metacpan.org/author/PRBRENAN>

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