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

Re: RFC 0004 - defer {} syntax

Thread Previous | Thread Next
From:
David Nicol
Date:
June 18, 2021 17:36
Subject:
Re: RFC 0004 - defer {} syntax
Message ID:
CAFwScO9Q_szKG1dD01Ln5pg7iaS=+0jU9fCVmYV4QKY1LH7Mjw@mail.gmail.com
very true. The rest of the single exit point pattern is having some
discipline about not exiting except via it.



>>   Whereas the defer "enqueues a block of code for later execution, when
>> control leaves its surrounding scope for whatever reason", so as long as
>> the defer statement is reached, the block will eventually run.  (Well,
>> untimely program termination will prevent it, I guess.)
>>
>
> Yes, the primary usecase for scope guards is to run regardless of whether
> the scope is normally exited. Abnormal scope exits include exceptions, loop
> control flow, and returning from a subroutine, among more esoteric options.
>

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