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

Re: Adding a try/catch syntax to Perl

Thread Previous | Thread Next
Philip R Brenan
January 23, 2021 14:31
Re: Adding a try/catch syntax to Perl
Message ID:
One of the many advantages of the *fail* syntax:

{ A...} *fail* {B ....}  *fail* {C ....} *fail* { {D ....}  *fail* {E ....}

Is that it can be easily chained and nested in order to express the idea
that the code designed to handle the failure is every bit as likely to fail
as the code thought likely to fail.

Proof by contradiction: If you can write code in the catch block that does
not fail then why can you not write code in the try block that does not
fail in the first place and thereby obviate the need for a try/catch at all?

It also lends itself well to use in expressions:
a / b fail NaN
allowing us to avoid discrimination against expressions over statements.

It is easy to teach and document because it is minimal: there is no
plethora of extraneous keywords and parentheses to explain to the student.

By using a more expressive syntax we move gracefully ahead of the
competition: we give people a reason to write Perl in a syntax so
beautifully free of any unwanted parentheses and keywords that they look
upon the messy alternatives provided by the lesser languages with horror.

G. H. Hardy: Beauty is the first test: there is no permanent place in the
world for ugly mathematics (or programming languages).

Ludwig Wittgenstein: “Die Grenzen meiner Sprache bedeuten die Grenzen
meiner Welt.”

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About