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

Re: Review of `defer` (was: FINALLY - ready for comments/review)

Thread Previous | Thread Next
Paul "LeoNerd" Evans
July 28, 2021 20:08
Re: Review of `defer` (was: FINALLY - ready for comments/review)
Message ID:
On Wed, 28 Jul 2021 19:33:54 +0000
Oodler 577 via perl5-porters <> wrote:

> I'm still left to wonder that if, "defer" and "finally" are so similar
> and in fact tied to a similar mechanism underneath; do they need to be
> called different things - or is there an opportunity to simply go with
> one or the other?

One could equally wonder why we'd need both `if` and `unless`, or both
`while` and `until`. Many language concepts can be expressed in terms
of others.

It's OK to have more than one similar way to express certain ideas.
People can pick whatever is the most convenient at the time. Some
situations will call for try/finally, other situations will call for

Already right now there's loads of code using things like Scope::Guard
that can be neatened up to using defer instead, without needing to
consider try/finally.

I think in a language as diverse as Perl, there is scope for both
[pardon the pun].

Paul "LeoNerd" Evans      |  |

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