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:58
Subject:
Re: Adding a try/catch syntax to Perl
Message ID:
CALhwFRnc9HnEu7PiSQCwmvq3Cub2u7uJrSc=FFR_2+O6FvWrxw@mail.gmail.com
If we had an LR parser in play that did not require an early commitment to
the rule to be expanded, instead of an LL one that does, we could offer the
more expressive:

  {...}  fail  {...}

where *fail* is a dyadic operator linking the *try* part to the *catch*
part.

But of course that would be advanced language technology that transcended
Java or Javascript when our goal, these days, is, apparently, to be as much
like them as possible, yea verily, right down to the very last parenthesis:

We are not now that strength which in old days
Moved earth and heaven;


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