develooper Front page | perl.perl5.porters | Postings from March 2020

Re: Thoughts in the direction of a core try/catch syntax

Thread Previous | Thread Next
From:
Paul "LeoNerd" Evans
Date:
March 7, 2020 17:07
Subject:
Re: Thoughts in the direction of a core try/catch syntax
Message ID:
20200307170649.2971ea72@shy.leonerd.org.uk
On Fri, 06 Mar 2020 00:08:53 +0000
hv@crypt.org wrote:

> I'd definitely like to see this available in core, preferably by means
> of option 2.
> 
> I'll note though that any new semantics made available by encorement
> will _not_ have benefited from the battle-hardening of the CPAN
> implementation, and we don't have a good recent record of getting such
> things right first time.
> 
> The list-returning capability does not sound problematic from a
> semantic point of view. The type-dispatch implicit in efficient
> propagation of unhandled exceptions sounds a lot harder, so if at all
> possible I'd suggest again experimenting with that in CPAN - adding
> (temporary, experimental) hooks as necessary to permit it - rather
> than trying to introduce it in core ab initio.

Yes; that's certainly true. Trying to experiment with the type dispatch
directly in core sounds like a bad idea.

Given the overall option 2 then I can see two variations on how that
might progress:

  2a) Continue to experiment on CPAN with the type dispatch until that
      seems good, then import the whole lot into core in one go;

  2b) Import the simpler syntax as it currently stands (and possibly
      even without the `catch my $e ...` form), then experiment on CPAN
      with the typing and do a second round into core afterwards.

I don't think 2b would necessarily be too bad. It compares e.g. with
sub signatures, which turned up in a relatively simple form early on
and had a couple of versions of iteration where more features were
added and expanded on the "obvious holes" left in the first one. I
could see a simple try/catch being added as a first step while
preserving the lexical gap between "catch" and its brace-delimited body
for where to put some as-yet-undecided syntax for that type dispatch.

A potential issue with trying to design the type dispatch though is
that it might have some overlap with my thoughts on "dumb-match"; see
the other thread. The reason I bring them both up at the same time, is
that there might be some utility in trying to design them both at once.

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

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