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

Re: RFC 0004 - defer {} syntax

Thread Previous | Thread Next
From:
Ben Bullock
Date:
June 21, 2021 10:11
Subject:
Re: RFC 0004 - defer {} syntax
Message ID:
CAN5Y6m-zfBxFE2WDu9KVZCgi1eEwB2g=Pn=+X-FNgCXynOJR-w@mail.gmail.com
On Mon, 21 Jun 2021 at 11:16, Eirik Berg Hanssen <
Eirik-Berg.Hanssen@allverden.no> wrote:

> On Mon, Jun 21, 2021 at 3:37 AM Ben Bullock <benkasminbullock@gmail.com>
> wrote:
>
>> I went back and checked, and I've actually said this in all of the
>> messages I've sent on this thread, and so far nobody has pointed out the
>> mistake in my understanding. Is there some way of sneaking out of if{}
>> without arriving at the end of the code?
>>
>
>   Yes?  Plenty of ways: An exception may sneak out (all the way to the
> first dynamically enclosing eval or similar); a return may sneak out (all
> the way out of the subroutine call); a next/last/redo may sneak out (all
> the way out of the first dynamically enclosing loop with matching label, if
> given); a goto LABEL may sneak out to some arbitrary LABEL.
>

No, that's not my point. If you have something like this

while (1) {
   if (something) {
      suddenlyexitif;
      print "Did not execute.\n";
   }
   print "Did execute\n";
}

you have to come up with something at suddenlyexitif which leaves the if
block which does not execute "print "Did not execute.\n"" but does execute
"print "Did execute\n"", without adding labels.

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